Did you know ... | Search Documentation: |
Profile for user lelsus |
list_to_set/2 | > _But why does list_to_set/2 demand 2 sorts?_ Because, as the description says, we are checking for _same elements *in the same order*_. You see by inspecting the [source code](https://www.swi-prolog.org/pldoc/doc/_SWI_/library/lists.pl?show=src#list_to_set/2): ~~~~ list_to_set(List, Set) :- must_be(list, List), % preserve the original positions of elements number_list(List, 1, Numbered), % fisrt sort by value in order to remove duplicates sort(1, @=<, Numbered, ONum), remove_dup_keys(ONum, NumSet), % then sort by original position, since we're % comparing the order of the elements as well sort(2, @=<, NumSet, ONumSet), pairs_keys(ONumSet, Set). ~~~~ |
Pack
tot: 1
| Version
(#older)
| Downloads
tot: 146
(#latest) | Rating
(#votes/
#comments) | Title |
---|---|---|---|---|
scasp | 1.1.430 | 14612 | Goal directed ASP solver |