Last active
December 10, 2016 14:16
-
-
Save christianromney/c8a5b5f0ad3137ebbfabfdad717ae3e6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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