Primes

LA home
Computing
FP
 PFL
  Examples
  Syntax
  Interpreter
   Primes

Sieve of Eratosthenese by parallel (||) processes.

let rec
 from = lambda n. fromchan!n -> from (n+1),

 fromchan = chan,

 sieve = lambda inch.
   inch?p -> output!p {must be prime} ->
   let rec
     filter = inch?x ->
       if (x/p)*p<>x then {not p|x} connect!x -> filter
                     else filter,

     connect = chan

   in (filter || sieve connect)


in  from 2 || sieve fromchan

{\fB Parallel Sieve of Eratosthenese. \fP}
example c1993.

A process is set up for each new prime -- to remove duplicates of that prime.


www:

free:
Linux
 Ubuntu operating-sys
OpenOffice office-suite
The GIMP ~photoshop
Firefox web-browser
FlashBlock flash on/off

pfl...
|   choice
|| parallel
-> sequence
? input act
! output act
chan new channel

© L. Allison   http://www.allisons.org/ll/   (or as otherwise indicated),
Created with "vi (Linux + Solaris)",  charset=iso-8859-1,  fetched Tuesday, 07-Feb-2012 17:56:54 EST.