[ library(hash) | Reference Manual | Alphabetic Index ]

hash_map(+Table, ++Key, ?Value)

Lookup or set Value as the value associated with Key
Table
A hash table
Key
a ground term
Value
Any term

Description

Unify Value with the table entry for Key, creating a fresh table entry if it does not exist yet. Behaves like
        hash_map(Map, Key, Value) :-
            ( hash_get(Map, Key, V) -> Value=V
            ; hash_set(Map, Key, Value)
            ).
With this predicate, the table behaves as if it were initialised with free variables for every possible key. This is most useful when the table is used to associate logical variables with ground keys.

Modes and Determinism

Examples

	?- hash_create(H),
           hash_map(H, one, X),
           hash_map(H, one, Y).

           X = X
           Y = X
           Yes (0.00s cpu)
    

See Also

hash_get / 3, hash_set / 3, hash_update / 5