public
/
Ack-5.5.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
Pristine Ack-5.5
[Ack-5.5.git]
/
lang
/
occam
/
test
/
sort.ocm
1
#include "dec.ocm"
2
-- This file contains a recursive call to sorter, so this is not really Occam.
3
4
var c:
5
seq
6
c:='*s'
7
proc comparator(value num, chan in, out)=
8
var old.num, new.num:
9
seq
10
old.num:=num
11
in ? new.num
12
while new.num
13
seq
14
in ? new.num
15
if
16
new.num<=old.num
17
out ! true; new.num
18
new.num>old.num
19
seq
20
out ! true; old.num
21
old.num:=new.num
22
in ? new.num
23
out ! true; old.num; false
24
:
25
proc sorter(chan out)=
26
chan in:
27
var num:
28
seq
29
decin(input, num, c)
30
if
31
c<0
32
out ! false
33
c>=0
34
par
35
sorter(in)
36
comparator(num, in, out)
37
:
38
chan out:
39
var num:
40
par
41
sorter(out)
42
seq
43
out ? num
44
while num
45
seq
46
out ? num
47
decout(output, num, 0)
48
output ! '*n'
49
out ? num