Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 6.6.6) Copyright (c) 1990-2013 University of Amsterdam, VU Amsterdam SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. Please visit http://www.swi-prolog.org for details. For help, use ?- help(Topic). or ?- apropos(Word). [1,11,20,10,2,12,19,9,3,13,18,8,4,14,17,7,5,15,16,6,*] Case = [1, 20, 2, 19, 3, 18, 4, 17, 5|...], Results = [1, 11, 20, 10, 2, 12, 19, 9, 3|...]. % halt