summaryrefslogtreecommitdiff
path: root/init.fnl
diff options
context:
space:
mode:
authorAndrey Listopadov <andreyorst@gmail.com>2021-03-13 11:31:54 +0300
committerAndrey Listopadov <andreyorst@gmail.com>2021-03-13 11:31:54 +0300
commit0a6045892511d056ee057354944ec6d8d996a7ca (patch)
treec0c30a15c7bfb878495e71bf21ef60ace01041c5 /init.fnl
parent7e32709879d00369b9b6677d7401c7c78a131223 (diff)
fix: allow `reduced` to return nil and false values
Diffstat (limited to 'init.fnl')
-rw-r--r--init.fnl20
1 files changed, 10 insertions, 10 deletions
diff --git a/init.fnl b/init.fnl
index a56da51..567ee4f 100644
--- a/init.fnl
+++ b/init.fnl
@@ -625,16 +625,16 @@ Reduce sequence of numbers with `add'
_ (let [[a b & rest] col]
(reduce f (f a b) rest)))))
([f val col]
- (if-some [reduced (when-some [m (getmetatable val)]
- (and m.cljlib/reduced
- (= m.cljlib/reduced.status :ready)
- m.cljlib/reduced.val))]
- reduced
- (let [col (or (seq col) (empty []))]
- (let [[x & xs] col]
- (if (nil? x)
- val
- (reduce f (f val x) xs)))))))
+ (let [m (getmetatable val)]
+ (if (and m
+ m.cljlib/reduced
+ (= m.cljlib/reduced.status :ready))
+ m.cljlib/reduced.val
+ (let [col (or (seq col) (empty []))]
+ (let [[x & xs] col]
+ (if (nil? x)
+ val
+ (reduce f (f val x) xs))))))))
(fn* core.reduced
"Wraps `x' in such a way so `reduce' will terminate early