Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Using IF and OR, I'm sure there is a better way

by phaylon (Curate)
on Dec 15, 2005 at 12:55 UTC ( [id://516941] : note . print w/replies, xml ) Need Help??


in reply to Using IF and OR, I'm sure there is a better way

I'd like to add 'any' from Perl6::Junction:
if ( any( 1, 2, 3 ) eq $n ) { ...

Ordinary morality is for ordinary people. -- Aleister Crowley

Replies are listed 'Best First'.
Re^2: Using IF and OR, I'm sure there is a better way
by swampyankee (Parson) on Dec 15, 2005 at 22:24 UTC

    Hey, it looks like the Perl6 people have been reading up on Fortran 90...(although it's quite possible any was adapted to Fortran90 from some other language).

    Fortran 90's any statement returns true of false if any element in an array meets a test condition, e.g.,

    integer,dimension(6) :: ar ar = (/1,3,4,5,6,7/) if(any(ar > 4) then # returns true if any element of ar is greater tha +n 4 call a_miracle_happens_here endif

    I'm still wondering why everybody was using regex for the test; it looks like a numerical comparison to me.