On Wed, Dec 11, 2002 at 08:44:00PM -0500, Jeff 'japhy' Pinyan wrote:
> On Dec 11, Paul Johnson said:
>
> >On Wed, Dec 11, 2002 at 10:52:53PM +0100, Jenda Krynicky wrote:
> >
> >> From: Rob Richardson <[EMAIL PROTECTED]>
> >> >
> >> > > @website[
> >> > > map $_->[0],
> >> > > sort { $b->[1] <=> $a->[1] }
> >> > > map [ $_, $array[$_] ],
> >> > > 0 .. $#array
> >> > > ] = 1 .. @array;
> >>
> >> This is something most Perl programmers would have a hard time
> >> understanding. The construct comes from functional languages.
> >
> >OK. I admit it. I like functional programming :-)
>
> No one has noted yet that the Schwartzian transform here is TOTALLY
> redundant.
>
> @website[
> sort { $array[$b] <=> $array[$a] } 0 .. $#array
> ] = 1 ..@array;
But sometimes redundancy is important in critical systems.
Of course if you are worried about a few little cycles, or the elegance
or maintainability of your algorithm, Jeff's version is fine too.
It's funny, when I was first writing that I thought there wasn't much
going into the array references, but I didn't pursue it. [Checks time
of posting] Ah, that's why. (Yeah, I know that's no excuse.)
Thanks, Jeff, for catching that. But think of all the fun we would have
missed.
[ Please insert smilies as required by law. ]
--
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]