Skip to content

Instantly share code, notes, and snippets.

@dawranliou
Last active April 26, 2018 01:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dawranliou/892b9cd720c85d7140b54205eb43f3d0 to your computer and use it in GitHub Desktop.
Save dawranliou/892b9cd720c85d7140b54205eb43f3d0 to your computer and use it in GitHub Desktop.
(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