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($_)?my %is_prime; @primes = grep { ( exists $is_prime{$_} and $is_prime{$_} ) or ( $is_prime{$_} = is_prime($_) ) } @numbers;
In reply to Re: Unable to Understand grep and hash use for prime no.
by soonix
in thread Unable to Understand grep and hash use for prime no.
by shankonit
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |