SPUG: Re: scalar swap challenge (SPOILER!)
Colin Meyer
cmeyer at helvella.org
Wed Oct 8 18:30:07 CDT 2003
On Wed, Oct 08, 2003 at 03:51:49PM -0700, Creede Lambard wrote:
> I think I sent my entry directly to Michael . . .
>
> my @stack;
>
> unshift @stack, $a;
> unshift @stack, $b;
> $a = shift @stack;
> $b = shift @stack;
>
> Note that this will work with any scalar, not just integers. Note that
> it also uses temporary storage, but not a temporary scalar.
The ^= solution occurred immediatly to me, because I had seen the c
language variety of this puzzler before. But I like your solution,
because it shows that you read the puzzle more thoroughly than me. ;-)
-Colin.
More information about the spug-list
mailing list