Ok, I found a possible problem, if i try to put all together, so write
something like this:
(defn lazy-reader [filename]
(with-open [fl (clojure.java.io/reader filename)]
(loop [bite (.read fl)]
(lazy-seq
(cons (bite) (recur (.read fl)))))))
Obviously doesn't work...
Any suggest of how fix that ?
Error: CompilerException java.lang.UnsupportedOperationException: Can
only recur from tail position, compiling:(NO_SOURCE_PATH:42)
On Dec 12, 12:42 pm, Simone Mosciatti <[email protected]> wrote:
> I thought to just put it into a take...
>
> (take number-of-byte-necessary (lazy-reader (clojure.java.io/reader
> "path/to/file")))
>
> On Dec 12, 12:34 pm, Stephen Compall <[email protected]>
> wrote:
>
>
>
>
>
>
>
> > On Mon, 2011-12-12 at 10:21 -0800, Simone Mosciatti wrote:
> > > (defn lazy-reader [fl]
> > > (lazy-seq
> > > (cons (.read fl) (lazy-reader fl))))
>
> > > Can work ? (0.03696 ms for 500 char)
> > > Possible problem ?
>
> > You need a termination case; your lazy-reader currently always yields an
> > infinite sequence.
>
> > --
> > Stephen Compall
> > ^aCollection allSatisfy: [:each|aCondition]: less is better
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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