Shuffling a list in PROLOG
问题 Simple question, how can I shuffle a list in PROLOG, so that A1 is my new list? shuffle([1,1,1,2,3,4],A1), I've tried a few predicates I found on the web but none of them seems to be working. Also found this but apparently it's not available anymore, according to SWI-PROLOG. 回答1: You can use random_permutation/2 . It is available in SWI-Prolog. ?- random_permutation([1,2,3],L). L = [1, 3, 2]. 来源: https://stackoverflow.com/questions/27431281/shuffling-a-list-in-prolog