Thinking of the <=> operator, this can be useful for things like this:

dataset := #(1 3 4 5 7 8 5 2 3 0).
mean := dataset average.
dataset collect: [ :each |  mean <=> each ]

-->  #(1 1 -1 -1 -1 -1 -1 1 1 1)

This we can also do with

coll := #(1 3 4 5 7 8 5 2 3 0).
mean := coll average.
coll collect: [ :each |  (mean - each) sign ]

but still.

Other use cases for <=> ?

Phil


On Fri, May 22, 2015 at 11:43 AM, Sven Van Caekenberghe <s...@stfx.eu>
wrote:

>
> > On 21 May 2015, at 16:50, Esteban A. Maringolo <emaring...@gmail.com>
> wrote:
> >
> > 2015-05-21 10:01 GMT-03:00 p...@highoctane.be <p...@highoctane.be>:
> >>
> >>
> >> On Thu, May 21, 2015 at 2:19 PM, Sean P. DeNigris <
> s...@clipperadams.com>
> >> wrote:
> >>>
> >>> Squeak 4.6 "Spur" Release Notes
> >>> http://wiki.squeak.org/squeak/6192
> >>
> >>
> >> Tag sort functions looks great to have around.
> >>
> >> About the spaceship operator (<=>), is this something  we'd like to have
> >> around? (I like it). http://en.wikipedia.org/wiki/Three-way_comparison
> >
> > http://www.smalltalkhub.com/#!/~emaringolo/SortFunctions
> >
> > I use them extensively.
> >
> > Esteban A. Maringolo
>
> I had a look.
>
> Apart from the fact that for some reason, the extensions on MAElement are
> in the Core package, hence loading just Core gave errors, things looked OK.
>
> This is generally useful, small and a very good example of super cool OO
> design.
>
> I would vote to integrate this (<=> and all).
>
> Sven
>
>
>

Reply via email to