Clojure Infinite sequence example
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 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