Clever, and really obscure; wouldn't this then require that _everyone_ that
writes a curried expression for the sort sub use ^a & ^b, and that everyone
writing a non-curried sort sub name their parameters a and b? I guess that
wouldn't necessarily be bad, but it would be restrictive.
Damian Conway wrote:
> Larry pointed out:
>
> > Yes, but has anyone pointed out that
> >
> > @out = sort ^b cmp ^a, @in;
> >
> > won't do what people will certainly think it ought to?
>
> It *will*, if C<sort> *names* the two values it passes to the
> comparator!
>
> E.g.:
>
> sub sort (^&comparator, @list) {
> for (1..@list**3) {
> my ($i, $j) = (rand(@list), rand(@list));
> @list[$i,$j] = @list[$j,$i]
> unless $comparator->(a: $list[$i], b: $list[$j]);
> }
> return @list;
> }
>
> (And now you know why I never fill in the IMPLEMENTATION section ;-)
>
> Damian
--
Glenn
=====
There are two kinds of people, those
who finish what they start, and so
on... -- Robert Byrne
_______________________________________________
Why pay for something you could get for free?
NetZero provides FREE Internet Access and Email
http://www.netzero.net/download/index.html