object
pairs
Useful predicates over lists of pairs (key-value terms).
logtalk_load(types(loader))
static, context_switching_calls
Usage: This object can be loaded independently of other entities in the
types
library by using the goallogtalk_load(types(pairs))
.
Public predicates
keys_values/3
Converts between a list of pairs and lists of keys and values. When converting to pairs, this predicate fails if the list of keys and the list of values have different lengths.
static
keys_values(Pairs,Keys,Values)
keys_values(+list(pair),-list,-list)
- one
keys_values(-list(pair),+list,+list)
- zero_or_one
keys/2
Returns a list of keys from a list of pairs.
static
keys(Pairs,Keys)
keys(+list(pair),-list)
- one
key/2
Enumerates by backtracking all keys from a list of pairs.
static
key(Pairs,Key)
key(+list(pair),-term)
- zero_or_more
values/2
Returns a list of values from a list of pairs.
static
values(Pairs,Values)
values(+list(pair),-list)
- one
value/3
Returns a value addressed by the given path (a key or a list of keys in the case of nested list of pairs). Fails if path does not exist.
static
value(Pairs,Path,Value)
value(+list(pair),+term,-term)
- zero_or_one
value(+list(pair),+list,-term)
- zero_or_one
transpose/2
Transposes a list of pairs by swapping each pair key and value. The relative order of the list elements is kept.
static
transpose(Pairs,TransposedPairs)
transpose(+list(pair),-list(pair))
- one
group_sorted_by_key/2
Groups pairs by key by sorting them and then constructing new pairs by grouping all values for a given key in a list. Keys are compared using equality. Relative order of values per key is kept. Resulting list of pairs is sorted by key.
static
group_sorted_by_key(Pairs,Groups)
group_sorted_by_key(+list(pair),-list(pair))
- one
group_consecutive_by_key/2
Groups pairs by constructing new pairs by grouping all values for consecutive key in a list. Keys are compared using equality. The relative order of the values for the same key is kept.
static
group_consecutive_by_key(Pairs,Groups)
group_consecutive_by_key(+list(pair),-list(pair))
- one
group_by_key/2
Same as the group_sorted_by_key/2
predicate. Deprecated.
static
group_by_key(Pairs,Groups)
group_by_key(+list(pair),-list(pair))
- one
map/3
Maps a list into pairs using a closure that applies to each list element to compute its key.
static
map(Closure,List,Pairs)
map(2,*,*)
map(@callable,+list,-list(pair))
- one
Protected predicates
(none)
Private predicates
(none)
Operators
(none)