diff options
| author | Andrey Orst <andreyorst@gmail.com> | 2020-11-02 21:40:08 +0300 |
|---|---|---|
| committer | Andrey Orst <andreyorst@gmail.com> | 2020-11-02 21:40:08 +0300 |
| commit | c1047d5f4fc30a9917ccd62b34e529d6a5ce4bbf (patch) | |
| tree | 1cf938dbe1553d7988cd001a4da22fb39a852b6e | |
| parent | e216b9be95e2c52f62e27294714ba6bb8fd58d1f (diff) | |
fix(core): optimize some doublework places
| -rw-r--r-- | core.fnl | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -294,16 +294,16 @@ ignored. Returns a table of results." (when (->> tbls (mapv #(~= (next $) nil)) (reduce #(and $1 $2))) - (cons (mapv #(first (safe-seq $)) tbls) (step (mapv rest tbls))))) + (cons (mapv #(. (safe-seq $) 1) tbls) (step (mapv #(do [(unpack $ 2)]) tbls))))) res []] - (each [_ v (ipairs (step (concat [t1 t2 t3] tbls)))] + (each [_ v (ipairs (step (consj tbls t3 t2 t1)))] (when-some [tmp (apply f v)] (insert res tmp))) res))) (fn* core.filter [pred tbl] (when-let [tbl (seq tbl)] - (let [f (first tbl) r (rest tbl)] + (let [f (. tbl 1) r [(unpack tbl 2)]] (if (pred f) (cons f (filter pred r)) (filter pred r))))) @@ -339,18 +339,18 @@ ignored. Returns a table of results." ([x y z] (f (g x y z))) ([x y z & args] (f (g x y z (unpack args)))))) ([f g & fs] - (reduce comp (concat [f g] fs)))) + (reduce comp (consj fs g f)))) (fn* core.every? [pred tbl] (if (empty? tbl) true - (pred (first tbl)) (every? pred (rest tbl)) + (pred (. tbl 1)) (every? pred [(unpack tbl 2)]) false)) (fn* core.some [pred tbl] (when-let [tbl (seq tbl)] - (or (pred (first tbl)) (some pred (rest tbl))))) + (or (pred (. tbl 1)) (some pred [(unpack tbl 2)])))) (set core.not-any? (comp #(not $) some)) |