Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: IF condition with a range

by ikegami (Patriarch)
on Jul 16, 2018 at 14:13 UTC ( [id://1218583]=note: print w/replies, xml ) Need Help??


in reply to IF condition with a range

Assuming integers,

if ($y-1 <= $x && $x <= $y+1)
or
if (abs($y-$x) <= 1)

Replies are listed 'Best First'.
Re^2: IF condition with a range
by Anonymous Monk on Jul 16, 2018 at 14:16 UTC
    True! Thank you!

      You could also use

      if (abs($y-$x) <= 1)

      (Added to earlier post)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1218583]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-03-29 00:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found