Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Multiple Conditional Statements

by hdb (Monsignor)
on Sep 11, 2013 at 15:44 UTC ( #1053514=note: print w/replies, xml ) Need Help??


in reply to Multiple Conditional Statements

...and a recursive option with error tolerant comparison...

use strict; use warnings; my $eps = 1e-10; sub distinct { return 1 if @_<2; # lists of 1 or empty lists never have dupli +cates my $first = shift; for( @_ ) { return 0 if abs($first - $_)<$eps; } return distinct( @_ ); } my @n = ( 1, 2, 3, 4, 4 ); print distinct( @n );

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1053514]
help
Chatterbox?
[marto]: so if someone just patched something, there's a problem
[marto]: or perhaps just a temporary thing
[LanX]: no I had a typo
[LanX]: jdporter: fixed it s/$p/$q/

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2017-12-14 21:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (410 votes). Check out past polls.

    Notices?