class LD::Patch::Algebra::Bind

The LD Patch ‘bind` operator.

The Bind operation is used to bind a single term to a variable.

@example simple value to variable binding

Bind ?x <http://example.org/s> . #=>
(bind ?x <http://example.org/s> ())

@example constant path (filter-forward.ldpatch)

Bind ?x <http://example.org/s> / <http://example.org/p1> . #=>
(bind ?x <http://example.org/s> (<http://example.org/p1>))

@example list index (path-at.ldpatch)

Bind ?x <http://example.org/s> / 1 . #=>
(bind ?x <http://example.org/s> ((index 1)))

@example reverse (path-backward.ldpath)

Bind ?x <http://example.org/s> / ^<http://example.org/p1> . #=>
(bind ?x <http://example.org/s> ((reverse <http://example.org/p1>)))

@example constraint (path-filter-equal.ldpatch)

Bind ?x <http://example.org/s> / <http://example.org/p2> [  / <http://example.org/l> = "b" ] . #=>
(bind ?x <http://example.org/s> (
  <http://example.org/p2>
  (constraint (<http://example.org/l>) "b")))

@example constraint (path-filter.ldpatch)

Bind ?x <http://example.org/s> / <http://example.org/p2> [  / <http://example.org/p1> ] . #=>
(bind ?x <http://example.org/s> (
  <http://example.org/p2>
  (constraint (<http://example.org/l>))))

@example starting with a literal

Bind ?x "a" / ^<http://example.org/l> / ^<http://example.org/p2> . #=>
(bind ?x "a" (
  (reverse <http://example.org/l>)
  (reverse <http://example.org/p2>)))

@example unicity (path-unicity.ldpath)

Bind ?x <http://example.org/s> / <http://example.org/p1> ! . #=>
SELECT ?x
WHERE {<http//example.org/s> <http://example.org/p1> ?x}
GROUP BY ?x
HAVING COUNT(?x) = 1
(bind ?x ?0
  ((pattern <http://example.org/s> <http://example.org/p1> ??0)
   (unique ??0)))