Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: IN-style operator for set of possible values

by kejohm (Hermit)
on Mar 16, 2012 at 01:47 UTC ( #959895=note: print w/replies, xml ) Need Help??

in reply to IN-style operator for set of possible values

You can always rely on the power of quantum computing:

use 5.012; use Quantum::Superpositions; my $myfruit = 'apples'; if ( $myfruit eq any( qw(bananas apples oranges) ) ) { print "I like $myfruit!"; } else { print "I don't like $myfruit!"; }

Replies are listed 'Best First'.
Re^2: IN-style operator for set of possible values
by BrowserUk (Pope) on Mar 16, 2012 at 02:59 UTC
    You can always rely on the power of quantum computing:

    That's like choosing the Large Hadron Collider to pop your corn, just because it has a long and impressive name. It might get there eventually, but it takes an awful long time.

    Below, Quantum::Superpositions::any() takes 15 whole seconds to do what List::MoreUtils::any() does in 0.1 second. (plain ol'grep is quicker still!)

    Don't be overly impressed with the spiel, Q::S is just a bunch of (s-l-o-w) loops underneath:

    @a=1..1000; cmpthese -1,{ a=>q[ my$n=0; for my $i (1..1000) { Quantum::Superpositions::any( +@a ) eq $i and ++$n } ], b=>q[ my$n=0; for my $i (1..1000) { List::MoreUtils::any{ $i eq $_ + } @a and ++$n } ], };; (warning: too few iterations for a reliable count) s/iter a b a 15.4 -- -99% b 0.103 14834% --

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

      And this is probably one of several reasons that Damian Conway places Quantum::Superpositions in the "Damian modules you shouldn't use in production because their purpose is to explore and prototype future core language features" category in his Categorized Damian Modules list.

      The performance sucks, but, at least according to TheDamian, it was never intended to be used in production.


        Indeed. A note to that effect in the POD would prevent the unwary being caught out though.

      Yeah, you're right. It was more in the spirit of TIMTOWTDI.

      That's like choosing the Large Hadron Collider to pop your corn...

      mmm, quantum popcorn :)

        mmm, quantum popcorn :)

        You haven't lived until you've tried quantum popcorn. I like mine seasoned with flakes of 5-dimensional branes.

        perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://959895]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2018-07-18 04:42 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (383 votes). Check out past polls.