function | since v0.0-927 | clojure.core/get-in | Edit |
(get-in m ks)
(get-in m ks not-found)
Returns the value in a nested associative structure, where ks
is a sequence of
keys.
Returns nil if the key is not found, or not-found
if supplied.
Returns the value in a nested associative structure, where ks is a sequence of keys. Returns nil if the key is not present, or the not-found value if supplied.
(defn get-in
{:added "1.2"
:static true}
([m ks]
(loop [m m
ks (seq ks)]
(if (nil? ks)
m
(recur (get m (first ks))
(next ks)))))
([m ks not-found]
(loop [sentinel lookup-sentinel
m m
ks (seq ks)]
(if-not (nil? ks)
(let [m (get m (first ks) sentinel)]
(if (identical? sentinel m)
not-found
(recur sentinel m (next ks))))
m))))