On Wed, Sep 06, 2000 at 09:43:03AM -0500, Garrett Goebel wrote:
> From: Jonas Liljegren [mailto:[EMAIL PROTECTED]]
> > 
> > Does any other RFC give the equivalent to an 'in' operator?
> > 
> > I have a couple of times noticed that beginners in programming want to
> > write if( $a eq ($b or $c or $d)){...} and expects it to mean
> > if( $a eq $b or $a eq $c or $a eq $d ){...}.
> > 
> > I think it's a natural human reaction to not be repetative. An 'in'
> > operator will help here. It could be something like this:
> > 
> >     $a in @b; # Has @b any element exactly the same as $a
> >     $a == in @b; # Is any element numericaly the same as $a
> >     $a eq in @b;
> >     $a > in @b;  # Is $a bigger than any element in @b?
> >     $a not in @b; # Yes. Make 'not' context dependent modifier for in.
> 
>       grep { ref($a) eq ref($b) } @b)  # Same type?
>       grep { $a == $_ } @b)
>       grep { $a eq $_ } @b)
>       grep { $a > $_ } @b)
>       (grep { $a != $_ } @b) == @b)

        grep { $_ == 1 } 1..1_000_000

grep doesn't short-circuit.

-- 
$jhi++; # http://www.iki.fi/jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen

Reply via email to