in reply to Re: Ternary Operator: Condition-Negation
in thread Ternary Operator: Condition-Negation
Simplify?for ($#history .. 0) { my $temp = pop @history; next if exists $history{ $temp }; $history{ $temp } ++; unshift @history; }
Why not follow through when you get to that point? Something like this seems just fine to me:
my %seen; for (1 .. @history) { my $item = pop @history; unshift @history, $item unless $seen{$item}++; }
Sure, the temporary variable is still there. But then, do you really prefer something along these lines?
my %seen; for (1 .. @history) { unshift @history, $seen{$history[-1]}++ ? $#history-- && () : pop +@history; }
I didn't think so either. ;-)
— Arien
|
|---|