Primes

home
 Bib
 Algorithms
 Bioinfo
 FP
 Logic
 MML
 Prog.Lang
and the
 mmlist

FP
 PFL
  Examples
  Syntax

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.


Coding Ockham's Razor, L. Allison, Springer

A Practical Introduction to Denotational Semantics, L. Allison, CUP

Linux
 Ubuntu
free op. sys.
OpenOffice
free office suite
The GIMP
~ free photoshop
Firefox
web browser

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

© L. Allison   http://www.allisons.org/ll/   (or as otherwise indicated),
Faculty of Information Technology (Clayton), Monash University, Australia 3800 (6/'05 was School of Computer Science and Software Engineering, Fac. Info. Tech., Monash University,
was Department of Computer Science, Fac. Comp. & Info. Tech., '89 was Department of Computer Science, Fac. Sci., '68-'71 was Department of Information Science, Fac. Sci.)
Created with "vi (Linux + Solaris)",  charset=iso-8859-1,  fetched Friday, 01-Jul-2022 18:26:01 AEST.