Created
April 27, 2017 19:13
-
-
Save ekaitz-zarraga/f7907b40ce6c64d908fa0bdf47b594a2 to your computer and use it in GitHub Desktop.
Clojure Infinite sequence example
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
(defn lista | |
([] (lista 1)) | |
([one] (lazy-seq (cons one (lista (+ one 1)))))) | |
(defn fibo | |
([] (fibo 0 1)) | |
([one two] (lazy-seq (cons one (fibo two (+ one two )))))) | |
(defn -main | |
[& args] | |
(println (take 10 (lista))) | |
(println (take 10 (fibo)))) | |
(-main) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment