summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Listopadov <andreyorst@gmail.com>2021-10-17 13:01:27 +0300
committerAndrey Listopadov <andreyorst@gmail.com>2021-10-17 13:01:27 +0300
commit3421b872152e99c119e1e9803d19651d574c77af (patch)
treec1f29d419937c0a452806732d4266de0011043c4
parent524bd990d1539b6620ad26c81b28273f3c9d3ce4 (diff)
fix: tweak apply
-rw-r--r--init.fnl11
1 files changed, 6 insertions, 5 deletions
diff --git a/init.fnl b/init.fnl
index 01bd56d..7dd1696 100644
--- a/init.fnl
+++ b/init.fnl
@@ -77,11 +77,12 @@ Applying `add' to different amount of arguments:
([f a b args] (f a b (_unpack args)))
([f a b c args] (f a b c (_unpack args)))
([f a b c d & args]
- (let [flat-args (empty [])]
- (for [i 1 (- (length args) 1)]
- (insert flat-args (. args i)))
- (each [_ a (ipairs (. args (length args)))]
- (insert flat-args a))
+ (let [flat-args []
+ len (- (length args) 1)]
+ (for [i 1 len]
+ (tset flat-args i (. args i)))
+ (each [i a (ipairs (. args (+ len 1)))]
+ (tset flat-args (+ i len) a))
(f a b c d (_unpack flat-args)))))
(defn core.add