On Wed, Dec 14, 2011 at 11:47 PM, Simone Mosciatti mweb@gmail.com wrote:
Ok thank you so much, i got it.
Thanks again ;-)
You're welcome.
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to
On Wed, Dec 14, 2011 at 12:04 AM, Simone Mosciatti mweb@gmail.com wrote:
Thank you so much, just one last thing, why you use a char-array ?
Reader returns chars.
If I want use a byte-array, and no map all the whole sequence ?
Use an InputStream rather than a reader if you're reading
Ok thank you so much, i got it.
Thanks again ;-)
Simone
On Dec 14, 3:22 am, Cedric Greevey cgree...@gmail.com wrote:
On Wed, Dec 14, 2011 at 12:04 AM, Simone Mosciatti mweb@gmail.com wrote:
Thank you so much, just one last thing, why you use a char-array ?
Reader returns chars.
If I
Here's a version I hacked up a while ago:
https://gist.github.com/1472163
-S
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be
No, I'm sure to not use all the sequence, so I will follow your second
advice, but...
Cause of my non-perfect english I've not really understand the last
part.
Who is the caller ?
You suggest something like this:
(let [fl (clojure.java.io/reader path/filename)
rd (lazy-reader fl)]
On Tue, Dec 13, 2011 at 10:14 PM, Simone Mosciatti mweb@gmail.com wrote:
No, I'm sure to not use all the sequence, so I will follow your second
advice, but...
Cause of my non-perfect english I've not really understand the last
part.
Who is the caller ?
You suggest something like this:
Ok, now by now i think to have understand...
To do right, I should build a macro similar to let where I pass the
filename and after execute the body close the stream, right ?
On Dec 13, 9:42 pm, Cedric Greevey cgree...@gmail.com wrote:
On Tue, Dec 13, 2011 at 10:14 PM, Simone Mosciatti
On Tue, Dec 13, 2011 at 11:12 PM, Simone Mosciatti mweb@gmail.com wrote:
Ok, now by now i think to have understand...
To do right, I should build a macro similar to let where I pass the
filename and after execute the body close the stream, right ?
Easier to just use the pre-existing one:
Where by now:
(defn lazy-reader [fl]
(assert ...)
(lazy-seq
(cons (.read fl) (lazy-reader fl
The first one ?
This means that I haven't understand nothing, right?
(I'm so sorry for this stupid question... :embarassed: )
On Dec 13, 10:23 pm, Cedric Greevey
On Tue, Dec 13, 2011 at 11:33 PM, Simone Mosciatti mweb@gmail.com wrote:
Where by now:
(defn lazy-reader [fl]
(assert ...)
(lazy-seq
(cons (.read fl) (lazy-reader fl
The first one ?
Er, buffering of the I/O is probably preferable, but that would
probably work OK in
Thank you so much, just one last thing, why you use a char-array ?
If I want use a byte-array, and no map all the whole sequence ?
On Dec 13, 10:39 pm, Cedric Greevey cgree...@gmail.com wrote:
On Tue, Dec 13, 2011 at 11:33 PM, Simone Mosciatti mweb@gmail.com wrote:
Where by now:
(defn
If I do just something like that:
(def fl (clojure.java.io/reader /path/to/file))
(defn lazy-reader [fl]
(lazy-seq
(cons (.read fl) (lazy-reader fl
Can work ? (0.03696 ms for 500 char)
Possible problem ?
On Dec 11, 9:49 pm, Stephen Compall stephen.comp...@gmail.com wrote:
On
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.
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 stephen.comp...@gmail.com
wrote:
On Mon, 2011-12-12 at 10:21 -0800, Simone Mosciatti wrote:
(defn lazy-reader [fl]
(lazy-seq
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
On Mon, 2011-12-12 at 20:03 -0800, Simone Mosciatti wrote:
Any suggest of how fix that ?
In general, avoid loop.
Specifically, try using letfn or (fn SOME-NAME-HERE [args...] ...) as
your recursion target.
--
Stephen Compall
^aCollection allSatisfy: [:each|aCondition]: less is better
--
You
You also probably want more efficiency. Try something closer to:
(defn lazy-reader [filename]
(let [rd (fn [rdr]
(let [buf (char-array 4096)
n (.read rdr buf 0 4096)]
(condp == n
-1 (.close rdr)
0 (recur rdr)
Hi Guys,
I'm pretty new of clojure so sorry for the maybe stupid question...
Anyway, i'm looking for read a file byte by byte, perfect would be get
a lazy-seq of every byte in the file, it's looks, for me, very weird
that there isn't a built-in or some easy way to do that, but I haven't
find
On Sat, 2011-12-10 at 23:13 -0800, Simone Mosciatti wrote:
Anyway, i'm looking for read a file byte by byte, perfect would be get
a lazy-seq of every byte in the file, it's looks, for me, very weird
that there isn't a built-in or some easy way to do that
The tradeoffs aren't universal enough
19 matches
Mail list logo