Skip to content

Instantly share code, notes, and snippets.

@jshultz
jshultz / pascal.clj
Created June 21, 2018 02:58
Pascal's Triangle in Clojure
(defn next-row [row]
(let [inner-section (mapv #(+ %1 %2) (butlast row) (rest row))]
(cons 1 (conj inner-section 1))))
(defn pascal
"row-count is the number of rows including the single '1'
at the top."
([row-count]
(pascal row-count identity))
([row-count print-fn]