Skip to content

Instantly share code, notes, and snippets.

@shayanjm
Last active August 29, 2015 14:04
Show Gist options
  • Save shayanjm/1010754249f47d6e97bb to your computer and use it in GitHub Desktop.
Save shayanjm/1010754249f47d6e97bb to your computer and use it in GitHub Desktop.
iter-seq function (Scala iterable -> Clojure lazy-seq) and implementation function
(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