Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Clojure Programming/Examples/API Examples/Mapping Operators

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

map user=> (map + [1 2 3 4] [1 2 3 4]) (2 4 6 8) reduce user=> (reduce * [2 3 4]) 24 ; sum the odd numbers to 100 ;; Not so beautiful code, see next example for a better approach (reduce #(+ %1 (if (= 1 (rem %2 2)) %2 0)) (range 100)) ; sum the odd numbers to 100 (Cleaner version) (reduce + (filter odd? (range 100))) apply user=> (apply str [1 2]) "12" (defn factorial [n] (apply * (range 2 (inc n))))