Skip to content

Instantly share code, notes, and snippets.

@christianromney
Last active December 10, 2016 14:16
Show Gist options
  • Save christianromney/c8a5b5f0ad3137ebbfabfdad717ae3e6 to your computer and use it in GitHub Desktop.
Save christianromney/c8a5b5f0ad3137ebbfabfdad717ae3e6 to your computer and use it in GitHub Desktop.
;; This buffer is for Clojure experiments and evaluation.
;; Press C-j to evaluate the last expression.
(fn trapezoid [v]
(let [row (fn [v]
(-> (vector (first v))
(into (map #(reduce +' %) (partition 2 1 v)))
(conj (last v))))]
(lazy-seq (cons v (trapezoid (row v))))))
(take 4 (trapezoid [2 3 2]))
(take 4 (iterate (fn [v]
(-> (vector (first v))
(into (map #(reduce +' %) (partition 2 1 v)))
(conj (last v)))) [2 3 2]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment