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

Re: Unable to Understand grep and hash use for prime no.

by soonix (Canon)
on Aug 04, 2015 at 18:59 UTC ( [id://1137415]=note: print w/replies, xml ) Need Help??


in reply to Unable to Understand grep and hash use for prime no.

my %is_prime; @primes = grep { ( exists $is_prime{$_} and $is_prime{$_} ) or ( $is_prime{$_} = is_prime($_) ) } @numbers;
Do I understand correctly that for numbers where $is_prime{$_} is false, the cached value is overwritten by a (supposedly superfluous) evaluation of is_prime($_)?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-25 16:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found