Module proto_vulcan::relation [−][src]
Expand description
Relations
Proto-vulcan relations are implemented as Rust-functions that have LTerm
-type
parameters, and Goal
return value. Because proto-vulcan is parametrized by
generic User
-type, functions must be made generic with respect to it if we want
to use anything other than the default DefaultUser
. A simple function example that
implements a relation that succeeds when argument s
is an empty list is declared as:
extern crate proto_vulcan;
use proto_vulcan::prelude::*;
pub fn emptyo<U: User, E: Engine<U>>(s: LTerm<U, E>) -> Goal<U, E> {
proto_vulcan!([] == s)
}
Recursion
The relation-constructor calls within proto_vulcan!
-macro are evaluated immediately when the
relation-constructor containing the macro is called; relations within proto-vulcan!
are just
function calls. Recursive relations must instead use proto_vulcan_closure!
-macro, that
puts the function calls and necessary context into a closure that will be evaluated later.
extern crate proto_vulcan;
use proto_vulcan::prelude::*;
pub fn append<U: User, E: Engine<U>>(l: LTerm<U, E>, s: LTerm<U, E>, ls: LTerm<U, E>) -> Goal<U, E> {
proto_vulcan_closure!(
match [l, s, ls] {
[[], x, x] => ,
[[x | l1], l2, [x | l3]] => append(l1, l2, l3),
}
)
}
Modules
CLP(FD)
Functions
A relation that succeeds an unbounded number of times.
A relation where l
, s
, and ls
are proper lists, such that ls
is s
appended to l
.
A relation such that the out
parameter is equal to rest
parameter appended to first
parameter. The first
parameter is the head of the list out
and the rest
is the tail.
Disequality relation.
Disequality relation for finite domains.
A relation which guarantees that all elements of l
are distinct from each other.
A relation that succeeds when s
is an empty list. This is equivalent to s == []
.
Equality relation.
A relation that fails.
A relation such that the first
is the first element of list
.
Associates the same domain to multiple variables
A relation that succeeds for each occurrence of x
in list l
.
A relation that succeeds once if x
is in list l
.
A relation that fails an unbounded number of times.
A relation that will permute xl into yl.
A relation where out
is equal to ls
with first occurrence of x
removed.
A relation such that rest
is list
without its first element.
A relation that succeeds.