We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c19ce81 commit eb4502cCopy full SHA for eb4502c
src/clj/clojure/core.clj
@@ -4910,12 +4910,19 @@
4910
"Returns the value in a nested associative structure,
4911
where ks is a sequence of ke(ys. Returns nil if the key is not present,
4912
or the not-found value if supplied."
4913
+ {:added "1.2"}
4914
([m ks]
- (reduce get m ks))
4915
+ (reduce get m ks))
4916
([m ks not-found]
- (if (seq ks)
4917
- (get (reduce get m (butlast ks)) (last ks) not-found)
4918
- m)))
+ (loop [sentinel (Object.)
+ m m
4919
+ ks (seq ks)]
4920
+ (if ks
4921
+ (let [m (get m (first ks) sentinel)]
4922
+ (if (identical? sentinel m)
4923
+ not-found
4924
+ (recur sentinel m (next ks))))
4925
+ m))))
4926
4927
(defn assoc-in
4928
"Associates a value in a nested associative structure, where ks is a
0 commit comments