Created
January 21, 2017 08:04
-
-
Save Jjunior130/b54f0ba6708ef290555ad8a0920a3009 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def tf | |
(comp | |
(partial mapv | |
#(if (coll? %) | |
(seq %) | |
%)) | |
(fn [[fs & rs]] | |
(cons (inc fs) rs)))) | |
;; 1654 ms | |
(def cpf (sp/comp-paths sp/FIRST)) | |
(def cpac? (sp/comp-paths sp/ALL coll?)) | |
(defn tf [x] | |
(->> x | |
(sp/compiled-transform cpf inc) | |
(sp/compiled-transform cpac? seq))) | |
;; 2117 ms | |
(def cpmp | |
(sp/comp-paths | |
(multi-path | |
[sp/FIRST (sp/terminal inc)] | |
[sp/ALL coll? (sp/terminal seq)]))) | |
(defn tf [x] | |
(sp/compiled-multi-transform t2 x)) | |
;; 2171 ms | |
(defn tf [x] | |
(sp/multi-transform* cpmp x)) | |
;; 2229 ms | |
(defn tf [x] | |
(->> x | |
(transform sp/FIRST inc) | |
(transform cpac? seq))) | |
;; 2277 ms | |
(defn tf [x] | |
(->> x | |
(transform sp/FIRST inc) | |
(transform [sp/ALL coll?] seq))) | |
;; 2948 ms | |
(defn tf [x] | |
(sp/multi-transform* (multi-path | |
[sp/FIRST (sp/terminal inc)] | |
[sp/ALL coll? (sp/terminal seq)]) x)) | |
;; 14176 ms | |
(time | |
(dotimes [i 100000] | |
(#'tf [4 8 [5] 3]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment