-
Notifications
You must be signed in to change notification settings - Fork 7
/
Generator.oz
48 lines (47 loc) · 1.02 KB
/
Generator.oz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
functor
export
Tails Count
require
BootValue(
newReadOnly : NewReadOnly
bindReadOnly: BindReadOnly)
at 'x-oz://boot/Value'
prepare
proc {Tails L R}
{NewReadOnly R}
thread {TailsLoop L R}end
end
proc {TailsLoop L R}
{WaitNeeded R}
case L
of nil then {BindReadOnly R nil}
[] _|L2 then R2={NewReadOnly} in
{BindReadOnly R L|R2}
{TailsLoop L2 R2}
end
end
proc {Count From To By R}
R={NewReadOnly}
in
thread
{if By<0 then CountDown else CountUp end
From To By R}
end
end
proc {CountDown From To By R}
{WaitNeeded R}
if From<To then {BindReadOnly R nil}
else R2={NewReadOnly} in
{BindReadOnly R From|R2}
{CountDown From+By To By R2}
end
end
proc {CountUp From To By R}
{WaitNeeded R}
if From>To then {BindReadOnly R nil}
else R2={NewReadOnly} in
{BindReadOnly R From|R2}
{CountUp From+By To By R2}
end
end
end