http://qs321.pair.com?node_id=824458


in reply to Re^7: in search of a more elegant if then else
in thread in search of a more elegant if then else

I have a vague preference for the last one, but only because it's most like how I'd actually write it:
my @filtered = do for $s.comb -> $a, $b { [ $a, $b ] if $a ne $b; }
or maybe slightly clearer would be:
my @filtered = gather for $s.comb -> $a, $b { take [ $a, $b ] if $a ne $b; }
But mathematicians are likely to prefer the list comprehension syntax, I suspect.