> I think this does the right thing too:
>
> @out = sort ^0 cmp ^a, @in;
>
> Since numbered placeholders have higher priority than named, it
> should create the function
>
> sub ($, $a) { $_[0] cmp $_[1] }
> When the curry is evaluated, the a: parameter is bound to $_[1]
> and the b: parameter fills in $_[0].
Yes.
> If this code is used instead:
>
> @out = sort ^1 cmp ^a, @in;
>
> Then a different function would be generated:
>
> sub ($a, $) { $_[1] cmp $_[0] }
>
> But the code still works.
Yes.
> That's kind of interesting -- the numbered placeholders define the
> ordering for the parameters passed anonymously, while the named
> placeholders define ordering for the parameters passed by keyword.
>
> I keep feeling like there's something here to trip on, but I
> can't find it.
Well, this:
@out = sort ^a cmp ^0, @in;
fails very badly (but could generate a "parameter $b not used in call to
curried expression" warning under C<use strict 'parameters'>).
Also:
@out = sort ^z cmp ^a, @in;
is counterintuitive (but would also generate a warning)
And both:
@out = sort ^l cmp ^0, @in;
and
@out = sort ^1 cmp ^O, @in;
are very nasty in a sans serif font :-)
> P.S. What the heck kind of sort is that?! O(N**3) random permutation
> sort?
Yup. Don't you just love it?! :-)