3 /* The Computer Language Shootout
4 http://shootout.alioth.debian.org
5 Contributed by Gavin Harrison */
7 times
:= args
at(1) asNumber
9 Coroutine
setStackSize(30000)
13 Thread
:= Object clone do(
15 if(next
, next
@@foo(n
+ 1), Lobby sum
= sum
+ n
+ 1)
28 args
at(1) asNumber
repeat(first
@@foo(0))
30 while(Coroutine yieldingCoros size
> 0, yield)
35 times := args at(1) asNumber
39 Thread := Coroutine clone do(
41 self coro := Coroutine clone setStackSize(15000)
42 coro setRunTarget(self)
43 coro setRunLocals(self)
44 coro setRunMessage(message(process))
56 if(next, next n := n + 1; next coro resume, Lobby sum = sum + n + 1; mainCoro resume)
63 mainCoro := Coroutine currentCoroutine
71 //Collector setDebug(true)
74 args at(1) asNumber repeat(first receive(0))
80 times := args at(1) asNumber
87 coro := Coroutine clone setStackSize(20000)
88 coro setRunTarget(Lobby)
89 coro setRunLocals(Lobby)
90 coro setRunMessage(message(send))
92 , Lobby sum = sum + 500; mainCoro resume)
94 mainCoro := Coroutine currentCoroutine
96 iters := args at(1) asNumber
100 //writeln("iter ", i, "\t", sum, "\t", (Collector maxAllocatedBytes/1000000) asString(0,2))