Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Comparing a value to a list of numbers

by Fletch (Chancellor)
on Jan 29, 2021 at 16:58 UTC ( #11127648=note: print w/replies, xml ) Need Help??


in reply to Comparing a value to a list of numbers

Straight from the examples in Quantum::Superpositions

use Quantum::Superpositions; if ($x == any($a, $b, $c)) { ... }

The cake is a lie.
The cake is a lie.
The cake is a lie.

Replies are listed 'Best First'.
Re^2: Comparing a value to a list of numbers
by LanX (Cardinal) on Jan 29, 2021 at 17:10 UTC
    IIRC this is implemented by any returning an object overloading the == operator. And there is maybe also tie'ing involved.

    Hence many movable and slow parts. Essentially a very sweet syntax coming with a cost.

    Question: is there also intelligent support for ranges? I'd buy into this if yes.

    like if ($x == any(1,2,5,6,9,10,[41,56]) { ...  } ?

    I suppose it's clear where the advantages are ...

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      No clue, although I completely glossed on the range requirement in the OP. Having seen that I'd change my answer to Set::IntSpan probably.

      The cake is a lie.
      The cake is a lie.
      The cake is a lie.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2021-04-10 22:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?