(module list)

Higher order

(filter :callable_term +list ?list)

Filter elements for which a goal succeeds

(filter Goal List FilterList) is true if and only if FilterList is a list containing only the elements of List that satisfy Goal.

(foldl :callable_term +list +term -term)

Reduce list to a single value

(foldl Goal Start List End) is true if and only if End is the result of applying Goal to the elements of List, from left to right, in a cumulative way, using Start as initial accumulator.

(foldr :callable_term +list +term -term)

Reduce list to a single value

(foldr Goal Start List End) is true if and only if End is the result of applying Goal to the elements of List, from right to left, in a cumulative way, using Start as initial accumulator.

(map :callable_term ?list)

Check if goal can be applied to a list

(map Goal List) is true if and only if Goal can be successfully applied to List. If Goal fails for any of List's elements, map/2 fails.

(map2 :callable_term ?list ?list)

Check if goal can be applied to several lists

As in map/2, but operating two elements at a time from the two lists. In this case, the Goal will consume two elements each time, one from each list.

(map3 :callable_term ?list ?list ?list)

Check if goal can be applied to several lists

As in map/2, but operating three elements at a time from the three lists. In this case, the Goal will consume three elements each time, one from each list.

(map4 :callable_term ?list ?list ?list ?list)

Check if goal can be applied to several lists

As in map/2, but operating four elements at a time from the four lists. In this case, the Goal will consume four elements each time, one from each list.

(map5 :callable_term ?list ?list ?list ?list ?list)

Check if goal can be applied to several lists

As in map/2, but operating five elements at a time from the five lists. In this case, the Goal will consume five elements each time, one from each list.

(map6 :callable_term ?list ?list ?list ?list ?list ?list)

Check if goal can be applied to several lists

As in map/2, but operating six elements at a time from the six lists. In this case, the Goal will consume six elements each time, one from each list.

(map7 :callable_term ?list ?list ?list ?list ?list ?list ?list)

Check if goal can be applied to several lists

As in map/2, but operating seven elements at a time from the seven lists. In this case, the Goal will consume seven elements each time, one from each list.

List manipulation

(append ?list ?list ?list)

Join two lists

(append L1 L2 L1_L2) is true and only true if L1_L2 is a list made up by concatenating L1 and L2.

(head ?list ?term)

First element of a list

(head List X) is true if X is the first element in List.

(length ?list ?integer)

Length of a list

(length List Integer) is true if and only if Integer is equal to the number of elements in List.

(member ?term ?list)

Check membership of element in list

(member X List) is true if and only if X is an element contained in List. If X is not instantiated, it will be instantiated with all the values in List.

(nonmember +term ?list)

Check non membership of element in list

(nonmember X List) is true if and only if X is not an element contained in List.

(nth ?integer ?list ?term)

Get the Nth element of a list

(nth Index List Item) is true if and only if Item is the element of List on the Index-th position. nth starts the index count at 0.

(permutation ?list ?list)

Permutation of list

(permutation List PermutateList) is true if and only if PermutateList is a permutation of List. If one of those parameters is uninstantiated, permutation/2 will calculate all the possible permutations. It's important to keep in mind that this predicate is computationally expensive, since a list of T length has T! permutations.

(powerset ?list ?list)

Powerset of a list

(powerset List Powerset) is true if and only if Powerset is an element of the powerset of List. If one of those parameters is uninstantiated, powerset/2 will calculate all the possible sets of the powerset.

(tail ?list ?list)

Tail of a list

(tail List Tail) is true if Tail is the tail of List.