fn
Creates a new lambda function
(fn [params*] exp*)
Description
Creates a new lambda function. You can store this using `def` keyword and call it later. See examples
Body
params - lambda parameters, ex: `[param1, param2]`
exp - any number of expressions. Last expression will be the return value when lambda get's evaluated.
Examples
(def add (fn [a, b] (+ a b)))
(add 2 3)
;;=> 5
(map (fn [x] (* x 2)) [1, 2, 3, 4])
;;=> [2, 4, 6, 8]
Was this helpful?