protocol
Dictionary protocol.
Paulo Moura
2.0
2010/2/26
static
(no dependencies on other files)
Converts a list of key-value pairs to a dictionary.
static
as_dictionary(Pairs,Dictionary)
as_dictionary(@list(pairs),-dictionary) – one
Converts a dictionary to a ordered list of key-value pairs.
static
as_list(Dictionary,Pairs)
as_list(@dictionary,-list(pairs)) – one
Clones a dictionary using the same keys but with all values unbound and returning a list of all the pairs in the new clone.
static
clone(Dictionary,Clone,ClonePairs)
clone(+tree,-tree,-list(pairs)) – one
Clones a dictionary using the same keys but with all values unbound and returning the list of all pairs in the dictionary and in the clone.
static
clone(Dictionary,Pairs,Clone,ClonePairs)
clone(+tree,-list(pairs),-tree,-list(pairs)) – one
Inserts a Key-Value pair into a dictionary, returning the updated dictionary. When the key already exists, the associated value is updated.
static
insert(OldDictionary,Key,Value,NewDictionary)
insert(+dictionary,+ground,@term,-dictionary) – one
Deletes a matching Key-Value pair from a dictionary, returning the updated dictionary.
static
delete(OldDictionary,Key,Value,NewDictionary)
delete(+dictionary,@ground,?term,-dictionary) – zero_or_one
Updates the value associated with Key in a dictionary, returning the updated dictionary. Fails if it cannot find the key.
static
update(OldDictionary,Key,NewValue,NewDictionary)
update(+dictionary,@ground,+term,-dictionary) – zero_or_one
Updates the value associated with Key in a dictionary, returning the updated dictionary. Fails if it cannot find the key or if the existing value does not match OldValue.
static
update(OldDictionary,Key,OldValue,NewValue,NewDictionary)
update(+dictionary,@ground,?term,+term,-dictionary) – zero_or_one
True if the dictionary is empty.
static
empty(Dictionary)
empty(@dictionary) – zero_or_one
Lookups a matching Key-Value pair from a dictionary.
static
lookup(Key,Value,Dictionary)
lookup(+ground,?term,@dictionary) – zero_or_one
lookup(-ground,?term,@dictionary) – zero_or_more
Returns the previous pair in a dictionary given a key.
static
previous(Dictionary,Key,Previous,Value)
previous(+dictionary,+key,-key,-value) – zero_or_one
Returns the next pair in a dictionary given a key.
static
next(Dictionary,Key,Next,Value)
next(+dictionary,+key,-key,-value) – zero_or_one
Returns the pair with the minimum key in a dictionary. Fails if the dictionary is empty.
static
min(Dictionary,Key,Value)
min(+dictionary,-key,-value) – zero_or_one
Returns the pair with the maximum key in a dictionary. Fails if the dictionary is empty.
static
max(Dictionary,Key,Value)
max(+dictionary,-key,-value) – zero_or_one
Deletes the pair with the minimum key from a dictionary, returning the deleted pair and the updated dictionary.
static
delete_min(OldDictionary,Key,Value,NewDictionary)
delete_min(+dictionary,-key,-value,-dictionary) – zero_or_one
Deletes the pair with the maximum key from a dictionary, returning the deleted pair and the updated dictionary.
static
delete_max(OldDictionary,Key,Value,NewDictionary)
delete_max(+dictionary,-key,-value,-dictionary) – zero_or_one
Returns a list with all dictionary keys.
static
keys(Dictionary,List)
keys(@dictionary,-list) – one
Maps a closure over each dictionary key-value pair. Fails if the mapped closure attempts to modify the keys.
static
map(Closure,Dictionary)
map(1,*)
map(@callable,+dictionary) – zero_or_more
Maps a closure over each dictionary key-value pair, returning the new dictionary. Fails if the mapped closure attempts to modify the keys.
static
map(Closure,OldDictionary,NewDictionary)
map(2,*,*)
map(@callable,+dictionary,-dictionary) – zero_or_more
Applies a closure to a specific key-value pair, returning the new dictionary. Fails if the key cannot be found or if the mapped closure attempts to modify the key.
static
apply(Closure,OldDictionary,Key,NewDictionary)
apply(2,*,*,*)
apply(+callable,+dictionary,+key,-dictionary) – zero_or_one
Number of dictionary entries.
static
size(Dictionary,Size)
size(@dictionary,?integer) – zero_or_one
(none)
(none)