On Tue, Nov 26, 2013 at 8:58 AM, Alex Miller wrote:
> Realizing a lazy sequence incurs overhead on every item. Chunked seqs
> amortize that cost by realizing a chunk of items at a time giving you
> better overall performance at the cost of less laziness.
>
And in this case that resulted in all t
Realizing a lazy sequence incurs overhead on every item. Chunked seqs amortize
that cost by realizing a chunk of items at a time giving you better overall
performance at the cost of less laziness.
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
But it is indeed a characteristic of the seq. The repl reads and evals the
for expression, which yields a lazy seq, so basically nothing has happened
at this point.
Then the repl needs to print the result. So first it prints an open
parenthesis as the result is a seq. Then it needs to evaluate the
Thanks Stefan.
I had a suspicion that it was to do with for's laziness but I had assumed
it was a characteristic of the seq it built rather than the forms inside
it. Seems a bit strange but will have to get used to it :-)
On Monday, November 25, 2013 2:11:45 PM UTC, Stefan Kamphausen wrote:
>
>
Thanks very much Cedric.
(What do you mean by: 'Clearly "board" is a chunked seq in this case.'?)
On Monday, November 25, 2013 1:58:36 PM UTC, Cedric Greevey wrote:
>
> Clearly "board" is a chunked seq in this case.
>
> Use doseq when you want side effects for-each of some seqable, but don't
> c
Hi Edward,
you are being hit by laziness here. Clojure's 'for' is not like the 'for'
you may know from other programming languages. It is made for list
comprehensions, that is it is building new list-y things. It does not do
this instantly, the items may be realized only when the caller ask
Clearly "board" is a chunked seq in this case.
Use doseq when you want side effects for-each of some seqable, but don't
care about the return values. The arguments for doseq are identical to
those for for, but a) doseq will return nil and b) if the output of for was
discarded (rather than the repl
Hi Edward,
I believe the return value of your expression is (nil nil nil nil ...), but
the printlns are forced just after the ( is printed.
Thanks,
Ambrose
On Mon, Nov 25, 2013 at 9:14 PM, wrote:
> Some (println) weirdness (board is a vector to vectors):
>
> (println (board 0))
> (println (bo
Some (println) weirdness (board is a vector to vectors):
(println (board 0))
(println (board 1))
(println (board 2))
(println (board 3))
(println (board 4))
(println (board 5))
(println (board 6))
(println (board 7))
Works as I would expect, printing to the console.
However:
(for [row board]