summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Orst <andreyorst@gmail.com>2020-10-21 05:17:05 +0300
committerAndrey Orst <andreyorst@gmail.com>2020-10-21 05:17:05 +0300
commite9560caad0ed11fcf96cf383c515729b2b962446 (patch)
tree59fe097533c0d5375b74009bbe0a717e5b13b490
parent9464ed958be0144ec547f7f1a4ff62a37f1f46f1 (diff)
replace reduce3 with arity call
-rw-r--r--core.fnl13
1 files changed, 5 insertions, 8 deletions
diff --git a/core.fnl b/core.fnl
index 06a5603..b4875e6 100644
--- a/core.fnl
+++ b/core.fnl
@@ -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