This module implements common operations on Key-Value lists, also
known as Pairs. Pairs have great practical value, especially due
to
keysort/2 and the
library assoc.pl
.
This library is based on disussion in the SWI-Prolog mailinglist, including specifications from Quintus and a library proposal by Richard O'Keefe.
Deterministic if any argument is instantiated to a finite list and the others are either free or finite lists.
?- group_pairs_by_key([a-2, a-1, b-4], X). X = [a-[2,1], b-[4]]
Pairs | Key-Value list, sorted to the standard order of terms (as keysort/2 does) |
Joined | List of Key-Group, where Group is the list of Values associated with Key. |
map_list_to_pairs(length, ListOfLists, Pairs),