0

Why this predicate random_permutation doesn't work?

http://www.swi-prolog.org/pldoc/doc_for?object=random_permutation/2

?- use_module(library(random)).
%  library(pairs) compiled into pairs 0.00 sec, 8,880 bytes
% library(random) compiled into random 0.04 sec, 333,032 bytes
true.

?- L=[1,2,3,4,5], random_permutation(L,P).
ERROR: toplevel: Undefined procedure: random_permutation/2 (DWIM could not correct goal)

How can I make it work?

Leonardo
  • 358
  • 2
  • 17

1 Answers1

0

Please double check the version you are using. I am using 5.10.5 and the sizes of the libraries do not seem to match.

3 ?- use_module(library(random)).
%  library(pairs) compiled into pairs 0.00 sec, 4,568 bytes
% library(random) compiled into random 0.03 sec, 46,624 bytes
true.

4 ?- L=[1,2,3,4,5], random_permutation(L,K).
L = [1, 2, 3, 4, 5],
K = [1, 3, 2, 4, 5].
Alexander Serebrenik
  • 3,567
  • 2
  • 16
  • 32