This commit is contained in:
Adam Jeniski 2023-12-18 22:43:13 -05:00
parent 632dcade55
commit 8300fce484

View File

@ -33,8 +33,9 @@
[& ls] (let [r# (reverse ls)]
`(comp ~@r#)))
(defmacro s-fn
"wraps java static methods in a lambda so they can be passed as function objects"
(defmacro w-fn
"wraps s-expr such as java static methods or macro calls
in a lambda so they can be passed as function objects"
[f] `(fn [v#] (~f v#)))
(defn mapvf
@ -97,7 +98,7 @@
(mapv #((first %) (second %)))))
(comment
(map (s-fn Long/parseLong) ["123" "456"])
(map (w-fn Long/parseLong) ["123" "456"])
input-cache
((mapvf #(* 2 %)) [1 2])
@ -127,6 +128,8 @@
(+ (fib (- x 2))
(fib (dec x)))))
(map (w-fn log) [1 2])
;; 2000+ digit number generated in <16ms (leveraging polymorphism and big-int)
;; using a seemingly naive O(n!) implementation (leveraging defn-m, autocaching)
(time (fib 10000N))