John Porter declared:
Adam Turoff wrote:
> This message is not an RFC, nor is it an intent to add a feature to Perl
or specify a syntax for that feature[*].
Yay.
> We're all for making easy things easy, but the complexities of
> "map {} sort {} map {} @list" has always been befuddling to newbies,
especially when reading the code left-to-right.
So you think
@s =
map { $_->[0] }
sort { $a->[1] <=> $b->[1] }
map { [ $_, /num:(\d+)/ ] }
@t;
would be more clearly written as
@s = schwartzian(
{
second_map => sub { $_->[0] },
the_sort => sub { $a->[1] <=> $b->[1] }, first_map => sub { [
$_, /num:(\d+)/ ] },
},
@t );
-------------------------------
How about this?
@array=tsort
{ /num:(\d+)/ }
numerically #optional
@array;
is handled by something like
tsort(&;&@) {
my $t=shift;
my $s=shift || sub { $a cmp $b };
my @a=@_ || (something);
return
map { $_->[0] }
sort {
$a=$a->[1];
$b=$b->[1];
&$s;
}
map { [ $_ , $t ] }
@a;
}
It's totally untested, but you get the idea...
Or, a slightly different syntax from yours:
schwartzian {
first {...}
sort {...}
last {...}
} @ary;
--Brent Dax
Excuse typos, it's hahd to write on a Palm...