[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: comic-book-insult

From: Yuri Khan
Subject: Re: comic-book-insult
Date: Tue, 10 Sep 2019 01:26:26 +0700

On Tue, 10 Sep 2019 at 00:41, Emanuel Berg via Users list for the GNU
Emacs text editor <> wrote:

> > A predicate that returns a random boolean on
> > each invocation will easily violate any or all
> > of the above. [...]
> Interesting, however does Computer Science
> theory of sorting apply even when the intention
> is to randomize the elements?

Yes. If you use a predicate that does not satisfy the strict weak
ordering contract, the implementation of the sorting algorithm gives
you no warranties. For example, some implementations may fail to
terminate (i.e. enter an infinite loop), raise an error condition,
crash, spew warnings, or otherwise cause an effect other than a random

If you know the internals of a particular sort implementation, you
might conclude it does not suffer from any problems given an improper
comparison predicate; but it is bad form to depend on such
implementation details.

> > (concat (seq-map #'car (seq-sort-by #'cdr #'<
> > (seq-map (lambda (x) (cons x (random)))
> > (string-to-vector "@#$%&")))))
> The coder can't be that lazy:
>     seq-map: Symbol’s function definition is
>     void: seq-sort-by

Works for me, on 26.2.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]