Documentation improvements
- The parameter for .put/1 should be called "NewKeyValuePairs" instead of "New".
Did you know ... | Search Documentation: |
Predefined functions on dicts |
Dicts currently define the following reserved functions:
Key1/Key2/...
. Each key is
either an atom, small integer or a variable. While Dict.Key
throws an existence error, this function fails silently if a
key does not exist in the target dict. See also :</2,
which can be used to test for existence and unify multiple key values
from a dict. For example:
?- write(t{a:x}.get(a)). x ?- write(t{a:x}.get(b)). false. ?- write(t{a:t{b:x}}.get(a/b)). x
.
/2
would evaluate. replacing the value associated
with Key in a sub-dict of the dict on which the function
operates. See put_dict/4.
Below are some examples:
?- A = _{}.put(a, 1). A = _G7359{a:1}. ?- A = _{a:1}.put(a, 2). A = _G7377{a:2}. ?- A = _{a:1}.put(b/c, 2). A = _G1395{a:1, b:_G1584{c:2}}. ?- A = _{a:_{b:1}}.put(a/b, 2). A = _G1429{a:_G1425{b:2}}. ?- A = _{a:1}.put(a/b, 2). A = _G1395{a:_G1578{b:2}}.
plunit