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
- Re: RFC 76 (v1) Builtin: reduce Ariel Scolnicov
- Re: RFC 76 (v1) Builtin: reduce Jeremy Howard
- Re: RFC 76 (v1) Builtin: reduce Jarkko Hietaniemi
- Re: RFC 76 (v1) Builtin: reduce Larry Wall
- Re: RFC 76 (v1) Builtin: reduce Nathan Wiger
- Re: RFC 76 (v1) Builtin: reduce Jeremy Howard
- Re: RFC 76 (v1) Builtin: reduce Glenn Linderman
- Re: RFC 76 (v1) Builtin: reduce Damian Conway
- Re: RFC 76 (v1) Builtin: reduc... Jeremy Howard
- Re: RFC 76 (v1) Builtin: reduc... Damian Conway
- Re: RFC 76 (v1) Builtin: reduce Damian Conway
- Re: RFC 76 (v1) Builtin: reduce Glenn Linderman
- Re: RFC 76 (v1) Builtin: reduce Glenn Linderman
- Re: RFC 76 (v1) Builtin: reduce Damian Conway
- Re: RFC 76 (v1) Builtin: reduce Glenn Linderman
- Re: RFC 76 (v1) Builtin: reduce Damian Conway
- Re: RFC 76 (v1) Builtin: reduce Jeremy Howard
- Re: RFC 76 (v1) Builtin: reduce Nathan Wiger
- Re: RFC 76 (v1) Builtin: reduce Damian Conway
- Re: RFC 76 (v1) Builtin: reduce Nathan Wiger
- Re: RFC 76 (v1) Builtin: reduce Ken Fox
