AgentSieve.borg
AgentSieve.borg
{
`creeert zeef-agents
createsieve(next,collector,sievenr)::
{
prime:0;
data(num)::
{
if (prime = 0,
collector.prime(prime:=num),
if( (!((num\\prime)=0)), next.data(num)))};
agentclone(clone(),"sieve"+text(sievenr))
};
`verzameld primes en print ze
numcounter:0;
prime(p)::
{
if ((numcounter\\10)=0,display(eoln));
display(" "+text(p));
numcounter:=numcounter+1
};
data(p)::void;
`start de zeef met 30 agents
startsieve()::
{
col:beg:agentname;
for(i:20,i>0,i:=i-1, beg:=createsieve(beg,col,i));
for(i:2,i<200,i:=i+1, beg.data(i))
};
display("startsieve()")
}