It's a bit cleaner if ($state, @to_push) is returned.
my @b = list_reduce { undef, !@$_ || $b ne $_->[-1] ? $b : () } undef,
+ @a;
my @b = list_reduce { 0, !@$_ || $b ne $_->[-1] ? $b : () } 1, @a;
my @b = list_reduce { $b, defined($b) && $b ne $a ? $b : () } undef, @
+a;
my @b = list_reduce { $b, grep defined && $_ ne $a, $b } undef, @a;
(@a may not start with undef for the last two to work properly.)
This actually looks like map now (as it should). |