This commit is contained in:
Adam Jeniski 2023-12-18 22:12:22 -05:00
parent 131cfb08d1
commit 0c295d3f85

View File

@ -100,6 +100,22 @@
(map (s-fn Long/parseLong) ["123" "456"]) (map (s-fn Long/parseLong) ["123" "456"])
input-cache input-cache
((mapvf #(* 2 %)) [1 2])
((reducef + 0) [1 2])
((comp> #(* % 3)
#(+ % 2)
#(* % 4))
5)
;; is always 1, comp> is comp but reversed (to be the proper way round lol)
(->> 20
((juxt (comp> #(* % 3) #(+ % 2) #(* % 4))
(comp #(* % 4) #(+ % 2) #(* % 3))))
distinct
count)
(apply-each #(* % 2) #(+ % 5) 5 10) (apply-each #(* % 2) #(+ % 5) 5 10)
(apply-each-v #(* % 2) #(+ % 5) [5 10]) (apply-each-v #(* % 2) #(+ % 5) [5 10])
@ -109,8 +125,9 @@
(defn-m fib [x] (defn-m fib [x]
(if (< x 2) (if (< x 2)
x x
(+ (fib (dec x)) (+ (fib (- x 2))
(fib (- x 2))))) (fib (dec x)))))
(fib 20000N)
; ;; 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)))