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

Reply via email to