Standard Libraries

member, append, nth0/1, last, sum_list, max_list, msort, permutation, subtract, union...

maplist/2..7, foldl/4..7, include, exclude, partition pairs_keys_values, pairs_keys, pairs_values, transpose_pairs, map_list_to_pairs

AVL trees: empty_assoc, put_assoc, get_assoc, list_to_assoc ordered sets: ord_union, ord_subtract, ord_memberchk, ord_intersection aggregate_all/3, aggregate/3 limit, offset, order_by, distinct SWI dicts _{a:1}

strings, readutil, dcg/basics, pio text and parsing option/2, select_option/3 for option lists must_be/2, type_error/2...

debug/3, assertion/1 random_between, random_member, random_permutation clpfd, clpb, clpq, clpr, chr thread, thread_pool http/*, sgml, semweb/* web and semantic web csv, json (http/json), yaml graph algorithms (vertices_edges_to_ugraph, top_sort, reachable) occurs, terms term utilities (sub_term, mapargs) main, optparse date, format_time dates and times

24.1 Pairs, sorting by key

?- pairs_keys_values(Ps, [b, a], [2, 1]), keysort(Ps, S).   % S = [a-1, b-2]
?- map_list_to_pairs(atom_length, [ccc, a, bb], Ps), keysort(Ps, S), pairs_values(S, Vs).
   % Vs = [a, bb, ccc] — sort by computed key

24.2 Association lists (AVL trees)

?- list_to_assoc([a-1, b-2], A0), put_assoc(c, A0, 3, A1), get_assoc(b, A1, V), assoc_to_list(A1, L).

24.3 SWI-Prolog dicts

?- D = _{name: "Ann", age: 30}, X = D.name.             % X = "Ann"
?- D = point{x: 1, y: 2}, D2 = D.put(z, 3).
?- dict_pairs(D, Tag, Pairs).
?- get_dict(K, _{a:1, b:2}, V).                         % enumerate

24.4 Unweighted graphs

?- vertices_edges_to_ugraph([a, b, c], [a-b, b-c], G), top_sort(G, Order), reachable(a, G, R).

24.5 Dates

?- get_time(T), format_time(atom(A), '%Y-%m-%d %H:%M', T).
?- parse_time('2026-10-25T10:00:00Z', iso_8601, Stamp).
?- date_time_stamp(date(2026, 10, 25, 0, 0, 0, 0, -, -), S).