[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: can `shuffle-vector' be moved?
From: |
Thierry Volpiatto |
Subject: |
Re: can `shuffle-vector' be moved? |
Date: |
Fri, 13 May 2011 19:13:08 +0200 |
User-agent: |
Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.50 (gnu/linux) |
Stefan Monnier <address@hidden> writes:
>>> I don't know where it should live, but cookie1.el doesn't seem like the
>>> right place.
>>>
>>> It should be documented in "(elisp) Vector Functions" as well.
>>>
>>> Let me know if I should do this, please.
>>>
>>> Also this loop call from Pascal Bourguignon is a nice CL alternative to
>>> `shuffle-vector', though it uses the same algorithm:
>>>
>>> (defun shuffle (vector)
>>> "Re-orders randomly the vector."
>>> (loop
>>> for i from (1- (length vector)) downto 1
>>> do (rotatef (aref vector i) (aref vector (random i)))))
>
>> Nice.
>> Why is this limited to vectors? with elt it could work also with lists.
>
> Its algorithmic performance on lists would be poor (O(N²)).
> You want a different algorithm for lists.
Ok. Thanks.
--
A+ Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
- Re: can `shuffle-vector' be moved?, (continued)
- Re: can `shuffle-vector' be moved?, Ted Zlatanov, 2011/05/12
- Re: can `shuffle-vector' be moved?, Kevin Rodgers, 2011/05/13
- Re: can `shuffle-vector' be moved?, Ted Zlatanov, 2011/05/13
- Re: can `shuffle-vector' be moved?, Stefan Monnier, 2011/05/13
- Re: can `shuffle-vector' be moved?, Ted Zlatanov, 2011/05/13
- Re: can `shuffle-vector' be moved?, Stefan Monnier, 2011/05/13
- Re: can `shuffle-vector' be moved?, Ted Zlatanov, 2011/05/13
Re: can `shuffle-vector' be moved?, Thierry Volpiatto, 2011/05/13