Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re^8: in search of a more elegant if then else

by TimToady (Parson)
on Feb 21, 2010 at 03:13 UTC ( #824458=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://824458]
[tye]: okay, I know that Unix tracks the original login user (beyond "real UID"). What's a good way to get that in Perl?

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2017-06-23 18:38 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (554 votes). Check out past polls.