diff options
| author | Andrey Orst <andreyorst@gmail.com> | 2020-10-21 05:17:05 +0300 |
|---|---|---|
| committer | Andrey Orst <andreyorst@gmail.com> | 2020-10-21 05:17:05 +0300 |
| commit | e9560caad0ed11fcf96cf383c515729b2b962446 (patch) | |
| tree | 59fe097533c0d5375b74009bbe0a717e5b13b490 | |
| parent | 9464ed958be0144ec547f7f1a4ff62a37f1f46f1 (diff) | |
replace reduce3 with arity call
| -rw-r--r-- | core.fnl | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -41,11 +41,6 @@ (insert 1 x))) -(fn reduce3 [f val [x & xs]] - (if (not (= x nil)) - (reduce3 f (f val x) xs) - val)) - (fn* reduce "Reduce collection using function of two arguments and optional initial value. @@ -64,9 +59,11 @@ val and f is not called." 1 (. itbl 1) 2 (f (. itbl 1) (. itbl 2)) _ (let [[a b & rest] itbl] - (reduce3 f (f a b) rest)))) - ([f val itbl] - (reduce3 f val itbl))) + (reduce f (f a b) rest)))) + ([f val [x & xs]] + (if (not (= x nil)) + (reduce f (f val x) xs) + val))) (fn* mapv |