Re: randomize-list
- From: "Alex Mizrahi" <udodenko@xxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 30 May 2007 14:39:53 +0300
(message (Hello 'Matthias)
(you :wrote :on '(28 May 2007 02:26:48 -0700))
(
MB> Hmm... How about:
MB> (defun sort-list-shuffle (list)
MB> (sort list #'< :key (lambda (x) (declare (ignore x)) (random 1.0))))
MB> Would that work as well?
although some (naive, or over-optimized) implementations of sort can either
duplicate/omit elements, or hang, it apears that standard requires sort to
return something even if predicate or key is weird:
---
If the key and predicate always return, then the sorting operation will
always terminate, producing a sequence containing the same elements as
sequence (that is, the result is a permutation of sequence). This is
guaranteed even if the predicate does not really consistently represent a
total order (in which case the elements will be scrambled in some
unpredictable way, but no element will be lost).
---
and does not require predicate or key to be consistent:
---
If the key consistently returns meaningful keys,
---
i think "If" here implicitly allows key to return inconsistent and
non-meaningful keys :)
so i think this should work, although i wouldn't bet that all
implementations handle this correctly :)
)
(With-best-regards '(Alex Mizrahi) :aka 'killer_storm)
"I am everything you want and I am everything you need")
.
- References:
- randomize-list
- From: system8192
- Re: randomize-list
- From: John Thingstad
- Re: randomize-list
- From: Alex Mizrahi
- Re: randomize-list
- From: Matthias Benkard
- randomize-list
- Prev by Date: Re: n accuracy
- Next by Date: Re: n accuracy
- Previous by thread: Re: randomize-list
- Next by thread: Re: randomize-list
- Index(es):
Relevant Pages
|