Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Sorted by relevance     Sort by date
267 results for lazy stream
self-closing streams  
With-open's semantics are more like "look, we're leaving the scope of with-open,
so close the stream". Hi Graham, I've run into this too, haven't found a perfect
solution. Here's one thing I've done: (defn lazy-stream [r] ; r must be a
BufferedReader (if-let line (. r (readLine)) (lazy-cons line (lazy-stream r))
...
Jun 26 2008 by mac - 11 messages - 5 authors

Running out of memory when using filter?  
I got burned by the filter issue on my very first Clojure program, when I tried
to filter a lazy stream of 10-digit permutations to find all the permutations
with a certain property. The permutations which satisfied the property were far
enough apart that it caused a problem. This is the kind of program I typically
...
Dec 13 2008 by Rich Hickey - 59 messages - 10 authors

How to create and read from a stream of random characters?  
Here's one way to do that: (defn generate-data [size maxlength] (for [i (range
size)] (apply str (take (rand-int maxlength) (repeatedly #(char (+ (int \a) (
rand-int 26)))))))) But since this is returning a lazy stream (as your original
did), there's not much value in passing in the size: (defn seq-of-rand-strings
...
Jan 12 by Chouser - 4 messages - 3 authors

how to make lazy seq from socket input?  
kotka.de> wrote: hi, if you have a stream, you can basically do: (defn stream-
seq [stream] (take-while #(<= 0 %) (repeatedly #(.read stream)))) this will give
a character at a time. from there you can build the lines and turn it into a seq
of lines. or can you can to the lower level and use lazy-seq directly. ...
Oct 30 by timc - 5 messages - 4 authors

can "for" be enhanced to not have to take a binding?  
----use case---- i'm using it in combination with some java libraries. the
following seems like a very clojure-ish way of doing things. (for [:while (mouse
/hasevent)] (mouse/getevent)) so this returns a nice lazy stream of mouse events
, which can be processed however i like. smime.p7s 5kviewdownload --
May 8 by Laurent PETIT - 22 messages - 8 authors

on laziness and with-open  
b smith-mannschott bsmith.o...@gmail.com clojure on thu, jul 9, 2009 at 12:10,
mike<cki...@gmail.com> wrote: i wanted to grab bytes out of a stream, and didn't
see an analogue to reader from duck-streams, so i made my own: (defn byte-seq "
returns the bytes from stream as a lazy sequence of ints. stream must ...
Jul 9 by B Smith-Mannschott - 7 messages - 6 authors

lazy slurp  
(let [ch (. stream (read))] (if (== ch -1) (when close? nil) (. stream (close)))
(lazy-cons (char ch) (char-seq stream close?)))))) (defn char-seq-from-file [#^
String f] ; (with-open r (new java.io.FileReader f) ;; throws an error (let [r (
new java.io.FileReader f)] (char-seq r true))) Does this code guarantees ...
Apr 16 2008 by a r - 1 message - 1 author

Streams work  
One can easily have a seq "steal" a stream and not notice it before all memory
is used up by the seq. Calling seq on a stream yields a seq that will forever
own the stream - if you think about it a bit, you'll see why that has to be the
case. OTOH, that seq is lazy, so I'm not sure what the memory issue is. ...
Jan 23 by Rich Hickey - 37 messages - 13 authors

clojure scoping rules  
that can actually be advantageous; you can create lazy sequences and hand them
somewhere else, where the appropriate bindings will be enforced during
evaluation. (maybe selecting an output stream or queue dynamically while
processing a lazy stream of values, for example). perhaps i'm just an optimist,
...
Nov 22 by Richard Newman - 29 messages - 12 authors

lazy sequence question  
ataggart alex.tagg...@gmail.com clojure On Dec 9, 9:46 pm, Mark Engelberg <mark.
engelb...@gmail.com> wrote: There are only 9 items that satisfy your predicate.
(take 10 ...) demands a 10th, and it keeps searching the (iterate inc 1) stream
forever, endlessly searching for that 10th item it will never find. ...
Dec 10 by ataggart - 6 messages - 4 authors

 
Result Page:
1

2

3

4

5

6

7

8

9

10

Next
 
 

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google