in reply to Re: Elegance, dammit!
in thread Elegance, dammit!

Ah-HAH! :)

(I *really* liked that Perl6 solution, BTW; I see that I'm going to have to get off my lazy butt and dig into it.)

All of that - particularly Util's solution - has finally caused a reticent neuron to fire. Originally, I thought of this:

$out{shift @ref} = [splice @ref,0,2] while @ref;

...but there's a precedence problem with that, so that %out ends up containing stuff like

2 => [ 0, 1 ], 5 => [ 3, 4 ] etc.

so my final cut at it ends up being this:

die if @ref % 3; $out{$a} = [splice @ref,0,2] while $a = shift @ref;

I'm definitely up for seeing more solutions, though. You folks come up with some very pretty thought patterns. :)

Thank you all!