Article 4JYMC Conway: Infinite work is less work

Conway: Infinite work is less work

by
corbet
from LWN.net on (#4JYMC)
Damian Conway writesabout the power of infinite sequences in Perl 6.

The sequence of primes is just the sequence of positive integers,filtered (with a .grep) to keep only the ones that are prime.And, of course, Perl 6 already has a prime number tester: the built-in&is-prime function. The sequence of primes never changes, so we candeclare it as a constant:
 constant p = [ (1..a).grep( &is-prime ) ];
Now we need to extract just the strong and weak primes.
External Content
Source RSS or Atom Feed
Feed Location http://lwn.net/headlines/rss
Feed Title LWN.net
Feed Link https://lwn.net/
Reply 0 comments