yea true, the full sequence has to be realized before it is shuffled .. but
however the thing is that I am only interested in the first couple of
elements of the shuffled sequence. That is the lazy part I am talking about.
But I guess I won't be winning much there.. And again, I think I would have
got better performance if I had passed in a "Counted" collection which was
not true in my case..
Sunil.

On Mon, Jul 11, 2011 at 4:27 PM, Tassilo Horn <tass...@member.fsf.org>wrote:

> Sunil S Nandihalli <sunil.nandiha...@gmail.com> writes:
>
> Hi Sunil,
>
> >  I think a lazy version of shuffle would be a good addtion to the
> > core. I tried googling for one and found
> > http://ytakenaka.blogspot.com/2011/05/lazy-shuffle-clojure.html which
> > was infact slower than original shuffle and was unable to reproduce
> > the performance claims made there in.
>
> I think there is no way to implement a "good" lazy version of shuffle.
> Correct shuffling, i.e., the result should be a real pseudo-random
> permutation of all elements, can only be defined on finite seqs anyway.
> And there, one has to realize the given seq.  In the code you cite,
> there's
>
>  (defn lazy-shuffle [lst fetch-len]
>    (let [len (count lst)
>              ^^^^^^^^^^^
>
> which does exactly that.  So here only the cheap creation of the
> shuffled seq is lazy, but the possibly expensive calculation of the
> given seq is (and has to be done) directly.
>
> Bye,
> Tassilo
>
> --
> 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 patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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 patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to