On Tue, Mar 20, 2001 at 11:15:51PM -0500, John Porter wrote:
> @s = schwartzian(
> {
> second_map => sub { $_->[0] },
> the_sort => sub { $a->[1] <=> $b->[1] },
> first_map => sub { [ $_, /num:(\d+)/ ] },
> },
> @t );
Hm. I'd rather see:
schwartzian({/num:(\d+)/}, {^_<=>^_}, @t), and have perl figure out how to
do the forward and backword mappings. Hmm, I don't see why you couldn't
write that right now. (Other then synthatical shugar -- currying and
getting rid of the need for "sub {}"s.)
Indeed,
map $_->[0], sort {&$sort($a->[1], $b->[1])} map [$_, &$attrib($_)], @list;
does what I intendeded. (Where ex $sort = sub {$_[0] cmp $_[1]}, and
$attrib = sub {lc $_}.) (Of course, this doesn't always use the optimal
form.)
-=- James Mastros
--
The most beautiful thing we can experience is the mysterious. It is the
source of all true art and science. He to whom this emotion is a stranger,
who can no longer pause to wonder and stand wrapt in awe, is as good as dead.
-=- Albert Einstein
AIM: theorbtwo homepage: http://www.rtweb.net/theorb/