On Mar 25, 1:55 am, Mark Reid <[email protected]> wrote:
> I am very new to Clojure and I am trying to turn a <a
> href="http://www.biojava.org/docs/api/org/biojava/bio/seq/SequenceIterator.html">SequenceIterator</a>
> from the BioJava library into a lazy Clojure seq.
>
> The interface has two methods `hasNext()` and `nextSequence()` which
> have very similar semantics to `hasNext()` and `next()` for the
> standard Java Iterator interface.
Hi Mark,
You'll need to work at a lower level using cons and lazy-seq.
Something like this (untested):
(defn bio-iterator-seq [iterator]
(lazy-seq
(when (.hasNext iterator)
(cons (.nextSequence iterator) (bio-iterator-seq iterator)))))
-Stuart Sierra
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---