insert_if_absent function:
-
Can also be called as
put_if_absent -
Can also be called as
replace_if_absent -
Can also be called as
{-}
Add a new entry to a map if it has no such key. The first argument should be an object. The second argument should be a key. The third argument should be a value. If the object has that key, it will not be replaced.
Examples:
- running:
(insert_if_absent {}, "a", 1)will give:{"a": 1}
- running:
(insert_if_absent {"a": 10, "b": 22}, "a", -1)will give:{"a": 10, "b": 22}Because the object already has a value with theakey.
- running:
(insert_if_absent [], "a", 1)will return nothing
- running:
(insert_if_absent {}, 1, 1)will return nothing
- running:
(insert_if_absent {}, "1", ({} {} 1 1))will return nothing