0
votes

I am trying to use a supposedly built in procedure in SWI-Prolog. The procedure in question is sort/4.

The thing is, when I try to use it in my program I get the following error:

ERROR: Undefined procedure: sort/4
ERROR:     However, there are definitions for:
ERROR:         msort/2
ERROR:         sort/2

I don't understand because the documentation says its built-in, but Prolog doesn't know it. I really need to use this procedure

Would you know how to fix this issue ? I thought it was a matter of library and tried to add ":- use_module(library(lists))." at the beginning of my code but the situation remains the same.

Hope you can help me, have a good day

1
Please try figuring out what version of SWI-Prolog you are using. From the command line, that would be $ swipl --version. - user1812457
Thank you it works now ! You saved me a long time of trouble, thanks a lot !! - Manfred
@false: "sort/2 and keysort/2 ... certainly much faster" - not true, same speed. - jschimpf
@Boris: your comment should be an answer, really. Could serve as reference for future similar problems. - CapelliC
@false As it is at the moment, sort/4 covers the majority of use-cases I have seen. Definitely more versatile than sort/2, msort/2, keysort/2, and requires less code to use. - user1812457

1 Answers

2
votes

The sort/4 predicate as documented here is relatively new. If you get the latest stable or development version of SWI-Prolog it should be available. It is a built-in, not a part of a library.