14 ms·
I didn't spot Clojure here yet: (->> [1,2,3,4,5] (filter #(-> % (mod 3) (= 1))) (map #(* % %)) (reduce +)) #( ... ) is an anonymous
by nikonyrh 7y ago
I didn't spot Clojure here yet:
(->> [1,2,3,4,5]
(filter #(-> % (mod 3) (= 1)))
(map #(* % %))
(reduce +))
#( ... ) is an anonymous function, arrows are threading macros: https://clojure.org/guides/threading_macros https://clojure.org/guides/threading_macros
If you wanted more trickery you could play with transducers and compose them with "comp".
- fulafel 7y agoList comperhension version without threading: (reduce + (for [n [1, 2, 3, 4, 5] :when (= 1 (mod n 3))] (* n n)))