-- hamm.sa basic class for Hamming problem from Salishan book. -- use with shamm.sa for serial solution. -- used with phamm.sa, hmerge.sa for first parallel solution. class HAMM is attr primes:ARRAY{INT}; private attr stream:ARRAY{A_QUEUE{INT}}; attr n,bound:INT; --n =#primes>1 create(bd:INT, pr:ARRAY{INT}):SAME is res::=new; res.primes:=pr; res.bound:=bd; res.n:=pr.asize; res.stream:=#(pr.asize); loop i::=pr.ind!; res.stream[i]:=#(bd) end; --bd esitmates size return res; end; -- create generate!:INT is out:INT; loop i::=primes.ind!; stream[i].enq(primes[i]) end; loop out:=bound; loop i::=primes.ind!; out:=out.min(stream[i].top) end; if out=bound then quit else yield out end; --then enq multiples loop i::=primes.ind!; -- update the streams t::=out*primes[i]; if t