help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: avoid narrow-to-region (was: Re: replace-regexp)


From: Yuri Khan
Subject: Re: avoid narrow-to-region (was: Re: replace-regexp)
Date: Sun, 9 May 2021 17:06:33 +0700

On Sun, 9 May 2021 at 14:00, Emanuel Berg via Users list for the GNU
Emacs text editor <help-gnu-emacs@gnu.org> wrote:

> >>> Consistency: If (f a b) returns t once, it must return
> >>> t when called again with the same arguments. [...]
> >>
> >> But here, we want to randomize _every time_.
> >
> > Every time you do a random shuffle, but not within
> > a single shuffle.
>
> Why not?

>From the Wikipedia article I linked to previously, which you
apparently chose to read later:

===
In principle this shuffling method can even result in program failures
like endless loops or access violations, because the correctness of a
sorting algorithm may depend on properties of the order relation (like
transitivity) that a comparison producing random values will certainly
not have.[12] While this kind of behaviour should not occur with
sorting routines that never perform a comparison whose outcome can be
predicted with certainty (based on previous comparisons), there can be
valid reasons for deliberately making such comparisons. For instance
the fact that any element should compare equal to itself allows using
them as sentinel value for efficiency reasons, and if this is the
case, a random comparison function would break the sorting algorithm.
===



reply via email to

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