From 0a6045892511d056ee057354944ec6d8d996a7ca Mon Sep 17 00:00:00 2001 From: Andrey Listopadov Date: Sat, 13 Mar 2021 11:31:54 +0300 Subject: fix: allow `reduced` to return nil and false values --- init.fnl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'init.fnl') 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 -- cgit v1.2.3