Last active
April 26, 2018 01:06
-
-
Save dawranliou/892b9cd720c85d7140b54205eb43f3d0 to your computer and use it in GitHub Desktop.
This file contains 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
(defn tri-gen | |
([] (tri-gen 0 1)) | |
([tri-num n] | |
(lazy-seq (cons tri-num | |
(tri-gen (+ tri-num n) (inc n)))))) | |
(def tri-numbers (tri-gen)) | |
(take 7 tri-numbers) | |
;; (0 1 3 6 10 15 21) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment