LA home

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.

& [precomputed]

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

↑ © L. Allison,   (or as otherwise indicated).
Created with "vi (Linux)",  charset=iso-8859-1,   fetched Sunday, 26-May-2019 20:14:33 EDT.

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