Last active
August 29, 2015 14:04
-
-
Save shayanjm/1010754249f47d6e97bb to your computer and use it in GitHub Desktop.
iter-seq function (Scala iterable -> Clojure lazy-seq) and implementation function
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 iter-seq | |
"Takes a Scala iterable, and turns it into a lazy-seq" | |
[iter] | |
(lazy-seq | |
(when (.hasNext iter) | |
(cons (.next iter) | |
(iter-seq iter))))) | |
(defn iterable-seq | |
"Takes a Scala iterable s, and returns a lazy-seq of its contents." | |
[s] | |
(iter-seq (.iterator s))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment