|
Examples /
ConstraintsOnListsThe file list_constraints.ecl contains sample implementations of these constraints on lists:
These predicates all delay instead of making choices. They propagate changes in the list skeletons and the length bounds. Lengths are represented as lib(ic) integer variables. Basic examples:
?- len([a, b, c|Xs], L).
L = L{3 .. 1.0Inf}
There is 1 delayed goal.
Yes (0.00s cpu)
?- len([a, b, c|Xs], L), L = 5.
Xs = [_529, _533]
L = 5
Yes (0.00s cpu)
?- app([1, 2|Xs], [4, 5|Ys], Zs).
Xs = Xs
Ys = Ys
Zs = [1, 2, _272, _274|_327]
There is 1 delayed goal.
Yes (0.00s cpu)
?- app([1, 2|Xs], [4, 5|Ys], Zs), len(Zs,5).
Zs = [1, 2, _106, _108, _110]
There is 1 delayed goal.
Yes (0.00s cpu)
?- app([1, 2|Xs], [4, 5|Ys], Zs), len(Zs,5), Ys = [].
Xs = [_107]
Ys = []
Zs = [1, 2, _107, 4, 5]
Yes (0.00s cpu)
|