Just another Perl shrine | |
PerlMonks |
Re: (OT) Interview questions -- your response?by tadman (Prior) |
on Sep 04, 2002 at 07:32 UTC ( [id://194994]=note: print w/replies, xml ) | Need Help?? |
Here's my take on Q1, which isn't entirely original, but is self-contained:
my @c = do { my %tmp = map { $_ => 1 } @a; grep {$tmp{$_}} @b };Here's my take on Q2 which ended up the same as others: for (1..@foo/2) { @foo[$_-1,-$_] = @foo[-$_,$_-1]; }The first thing that came to mind was: @foo = map { pop(@foo) } 1..@foo;But that's not precisely an in-place version, even though you could argue that the temporary "array" only holds things that have been removed from @foo.
In Section
Meditations
|
|