Did you know ... Search Documentation:
Pack genutils -- prolog/listutils.pl
PublicShow source
 natural(+N) is semidet
natural(-N:natural) is multi
Means N is a natural number (includes 0). If N is a variable, succeeds an infinite number of times on backtracking, returning all natural numbers.
 int(+N) is semidet
int(-N:integer) is multi
Means N is an integer. If N is a variable, succeeds an infinite number of times on backtracking, returning all integers starting at zero and interleaving positive and negative values.
 enumerate(+L:list(A), -NL:list(pair(natural,A))) is det
enumerate(-L:list(A), -NL:list(pair(natural,A))) is nondet
 measure(+L:list(_), -N:list(natural)) is det
measure(-L:list(_), -N:list(natural)) is nondet
True when L and N are the same lenght and N is a sequence of integers starting at 1.
 print_list(+L:list) is det
Print a list, one item per line.
 printq_list(+L:list) is det
Print a list, one item per line, as with writeq/1.
 print_numbered_list(+L:list) is det
Print a list with numbered lines.
 cons(?Head:A, ?Tail:list(A), ?List:list(A)) is det
List constructor.
 decons(?Head:A, ?List:list(A), ?Tail:list(A)) is det
List deconstructor.
 rep(+N:natural, ?X:A, -L:list(A)) is det
rep(-N:natural, ?X:A, -L:list(A)) is multi
Make a list consisting of N repeats of the same term. If called with N unbount, creates progressively longer and longer lists on backtracking.
 drop(+N:natural, +In:list(A), -Out:list(A)) is semidet
True if removing exactly N elements from the head of In results in Out. Fails if there are fewer than N elements in In.
 take(+N:natural, +In:list(A), -Out:list(A)) is semidet
True when Out consists of the first N elements of Out. Fails if In contains fewer than N elements.
 dropc(+N:natural, +In:list(A), -Out:list(A)) is det
Unifies Out with the result of removing N elements from the head if In, or the empty list if In has fewer than N elements. (The 'c' is for a 'complete' as opposed to a 'partial' function.)
 takec(+N:natural, +In:list(A), -Out:list(A)) is semidet
Unifies Out with the first N elements of In, or the empty list if In has fewer than N elements. (The 'c' is for a 'complete' as opposed to a 'partial' function.)
 drop_while(+P:pred(A), +In:list(A), -Out:list(A)) is det
Remove all elements from head of In that are accepted by P and return the remained in Out.
 take_while(+P:pred(A), +In:list(A), -Out:list(A)) is det
Remove all elements from head of In that are accepted by P and return them in Out.
 split_at(+N:natural, -Prefix:list(A), -Suffix:list(A), +In:list(A)) is det
split_at(-N:natural, -Prefix:list(A), -Suffix:list(A), +In:list(A)) is det
True when Prefix is the length-N prefix of Items and Suffix is the list of remaining items. Also works in other modes, like append.
 same_length(+L1:list(_), +L2:list(_)) is det
same_length(-L1:list(_), -L2:list(_)) is nondet
True when L1 and L2 are lists of the same length.
 zip(+X:list(A), +Y:list(B), -Z:list(pair(A,B))) is det
zip(-X:list(A), -Y:list(B), +Z:list(pair(A,B))) is det
zip(?X:list(A), ?Y:list(B), ?Z:list(pair(A,B))) is nondet
True when Z is the list of pairs formed from corresponding elements of X and Y. The pair type is pair(A,B) ---> A-B.
 map_filter(+P:pred(+A,-B), +L1:list(A), -L2:list(B)) is det
Like maplist/3, but filtering out those elements of L2 for which P fails.
 foldr(P:pred(A,B,B), X:list(A), S1:B, S2:B) is det