diff options
| author | Andrey Listopadov <andreyorst@gmail.com> | 2021-10-17 13:01:27 +0300 |
|---|---|---|
| committer | Andrey Listopadov <andreyorst@gmail.com> | 2021-10-17 13:01:27 +0300 |
| commit | 3421b872152e99c119e1e9803d19651d574c77af (patch) | |
| tree | c1f29d419937c0a452806732d4266de0011043c4 /init.fnl | |
| parent | 524bd990d1539b6620ad26c81b28273f3c9d3ce4 (diff) | |
fix: tweak apply
Diffstat (limited to 'init.fnl')
| -rw-r--r-- | init.fnl | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -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 |