diff options
| author | Andrey Listopadov <andreyorst@gmail.com> | 2021-03-13 11:31:54 +0300 |
|---|---|---|
| committer | Andrey Listopadov <andreyorst@gmail.com> | 2021-03-13 11:31:54 +0300 |
| commit | 0a6045892511d056ee057354944ec6d8d996a7ca (patch) | |
| tree | c0c30a15c7bfb878495e71bf21ef60ace01041c5 /init.fnl | |
| parent | 7e32709879d00369b9b6677d7401c7c78a131223 (diff) | |
fix: allow `reduced` to return nil and false values
Diffstat (limited to 'init.fnl')
| -rw-r--r-- | init.fnl | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -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 |