Den mån 9 dec. 2024 21:36 <to...@tuxteam.de> skrev:

> On Mon, Dec 09, 2024 at 08:45:33PM +0100, Mikael Djurfeldt wrote:
> > On Mon, Dec 9, 2024 at 8:23 PM <to...@tuxteam.de> wrote:
> >
> > >   (lambda (p1 p2) (< (car p1) (car p2)))
> > >
> > > Then you'd need a corresponding equal, because otherwise you
> > > end up with things which are neither less nor equal nor greater,
> > > i.e. the ordering isn't total, which is bad for sorting :)
> > >
> >
> > `sort' assumes that the elements belong to a "strict total order", which
> > means that the connectedness-axiom is true, which means that a = b is
> > *equivalent to* not (a < b or a > b). So, we don't need equal.
>
> I think we need one of = or >, which we both don't have. We just have <,
> which is one too few.
>
No :)

I won't argue further, but for future reference I want to be more precise:
For the sort algorithms in Guile (and in C++ and all other languages and
implementations where you pass a predicate to sort) to produce a
predictable result, the < passed as second argument needs to define a
"strict weak order" on the set to be sorted. In practice, you will very
seldom run into situations where the difference between the different kinds
of order come into play. (But the classes in the class precedence list in
GOOPS is a partial order, so it has to be topologically sorted.)

Best regards,
Mikael

>
              • ... Mikael Djurfeldt
              • ... tomas
              • ... Mikael Djurfeldt
      • Re[2]: sorted? Stefan Schmiedl
        • Re: sorted... tomas
          • Re[2]:... Stefan Schmiedl
            • R... tomas
              • ... Mikael Djurfeldt
              • ... Mikael Djurfeldt
              • ... tomas
              • ... Mikael Djurfeldt
              • ... Maxime Devos via General Guile related discussions
              • ... Maxime Devos via General Guile related discussions
          • RE: so... Maxime Devos via General Guile related discussions
      • RE: sorted? Maxime Devos via General Guile related discussions
  • RE: sorted? Maxime Devos via General Guile related discussions

Reply via email to