Skip to content

Why does sort/2 make this fail? #2686

Answered by wkral
ocharles asked this question in Q&A
Discussion options

You must be logged in to vote

sort/2 removes duplicates from the list. I ran into this as well I believe that can make one of the lists a different size from the other, so maplist failed for me. Unfortunately, (or possibly by design) the example for that problem works and gives the correct answer when the duplicates are removed.

To get it to work with scryer I had to use keysort/2 but that requries you to use the pairs module so it's a little indirect. There may be other solutions I think it's pretty easy to implement quicksort with prolog so that might work.

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@triska
Comment options

@jjtolton
Comment options

@UWN
Comment options

@jjtolton
Comment options

@bakaq
Comment options

Answer selected by ocharles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants