5 ms·
;; python programmer who reads HN and Proggit (defn factorial [n] (reduce * (range 1 (inc n))))
by brehaut 17y ago
;; python programmer who reads HN and Proggit
(defn factorial
[n]
(reduce * (range 1 (inc n))))
- Torn 17y ago;; Any programmer reading HN long enough to experiment with some lisp / clojure ;) (defn factorial [n] (apply * (range 1 (+ n 1))))
- brehaut 17y agoI was torn between those two formulations, but decided on the reduce because the academic purity of an implicit hylomorphism ;) However, your formulation is more idiomatic of a lispy solution.