Hi,
Sorting recently came into discussion again. sort/2 sorts on standard
order of terms and removes duplicates. That is fine for most logical
manipulations, but often not adequate for applications. They may wish to
* Sort numerically (using ISO, 2.0 ends before 1).
* Sort case-insensitively
* Sort locale-dependent
* Reverse the order
* Remove or do not remove duplicates.
One can do some things using keysort, but not easily all of these.
Adding lots of predicates is probably not a good idea, as especially
reversing and duplicate-handling is orthogonal on the sorting criterium.
I'm tempted to define sort/3 as sort(+List, -Ordered, +Options), where
options provides:
* compare(:Goal)
Comparision predicate. Default compare/3
* reverse(+Boolean)
Iff =true=, sort largest first
* duplicates(+Action)
One of =keep= or =remove=
Using a couple of built-ins for Goal, we can still use an efficient
(foreign) implementation for the common cases. This notably requires
a compare_numbers/3
Opions?
Cheers --- Jan
------------
For further info, please visit
http://www.swi-prolog.org/To unsubscribe, send a plaintext mail with "unsubscribe prolog <e-mail>"
in its body to
majordomo@...