- Documentation
- Reference manual
- The SWI-Prolog library
- library(lists): List Manipulation
- member/2
 - append/3
 - append/2
 - prefix/2
 - select/3
 - selectchk/3
 - select/4
 - selectchk/4
 - nextto/3
 - delete/3
 - nth0/3
 - nth1/3
 - nth0/4
 - nth1/4
 - last/2
 - proper_length/2
 - same_length/2
 - reverse/2
 - permutation/2
 - flatten/2
 - max_member/2
 - min_member/2
 - sum_list/2
 - max_list/2
 - min_list/2
 - numlist/3
 - is_set/1
 - list_to_set/2
 - intersection/3
 - union/3
 - subset/2
 - subtract/3
 
 
 - library(lists): List Manipulation
 
 - The SWI-Prolog library
 - Packages
 
 - Reference manual
 
[nondet]permutation(?Xs, 
?Ys)
If both Xs and Ys are provided and both lists 
have equal length the order is |Xs|^2. 
Simply testing whether Xs is a permutation of Ys 
can be achieved in order log(|Xs|) 
using msort/2 as 
illustrated below with the semidet predicate is_permutation/2:
is_permutation(Xs, Ys) :- msort(Xs, Sorted), msort(Ys, Sorted).
The example below illustrates that Xs and Ys being proper lists is not a sufficient condition to use the above replacement.
?- permutation([1,2], [X,Y]). X = 1, Y = 2 ; X = 2, Y = 1 ; false.
- Errors
 type_error(list, Arg)if either argument is not a proper or partial list.