mirror of
https://github.com/Ajetski/advent-of-code.git
synced 2025-09-30 09:33:19 -09:00
fiddle
This commit is contained in:
parent
632dcade55
commit
8300fce484
@ -33,8 +33,9 @@
|
|||||||
[& ls] (let [r# (reverse ls)]
|
[& ls] (let [r# (reverse ls)]
|
||||||
`(comp ~@r#)))
|
`(comp ~@r#)))
|
||||||
|
|
||||||
(defmacro s-fn
|
(defmacro w-fn
|
||||||
"wraps java static methods in a lambda so they can be passed as function objects"
|
"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#)))
|
[f] `(fn [v#] (~f v#)))
|
||||||
|
|
||||||
(defn mapvf
|
(defn mapvf
|
||||||
@ -97,7 +98,7 @@
|
|||||||
(mapv #((first %) (second %)))))
|
(mapv #((first %) (second %)))))
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
(map (s-fn Long/parseLong) ["123" "456"])
|
(map (w-fn Long/parseLong) ["123" "456"])
|
||||||
input-cache
|
input-cache
|
||||||
|
|
||||||
((mapvf #(* 2 %)) [1 2])
|
((mapvf #(* 2 %)) [1 2])
|
||||||
@ -127,6 +128,8 @@
|
|||||||
(+ (fib (- x 2))
|
(+ (fib (- x 2))
|
||||||
(fib (dec x)))))
|
(fib (dec x)))))
|
||||||
|
|
||||||
|
(map (w-fn log) [1 2])
|
||||||
|
|
||||||
;; 2000+ digit number generated in <16ms (leveraging polymorphism and big-int)
|
;; 2000+ digit number generated in <16ms (leveraging polymorphism and big-int)
|
||||||
;; using a seemingly naive O(n!) implementation (leveraging defn-m, autocaching)
|
;; using a seemingly naive O(n!) implementation (leveraging defn-m, autocaching)
|
||||||
(time (fib 10000N))
|
(time (fib 10000N))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user