3 ms·
And Clojure has their way of handling unnamed variables in anonymous functions. ;; Single argument (fn [x] (* 2 x)) #(* 2 %) ;; Multiple arguments (fn [x y
by michaelteter 3y ago
And Clojure has their way of handling unnamed variables in anonymous functions.
;; Single argument
(fn [x] (* 2 x))
#(* 2 %)
;; Multiple arguments
(fn [x y] (+ x y))
#(+ %1 %2)
;; Remaining arguments
(fn [x & args] (reduce + x args))
#(reduce + % %&)
Example copied from this nice page - https://silviapan.com/blog/anonymous-functions-clojure/ https://silviapan.com/blog/anonymous-functions-clojure/