-
Notifications
You must be signed in to change notification settings - Fork 3
/
CounterFilter.oz
49 lines (47 loc) · 998 Bytes
/
CounterFilter.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
49
declare
fun {Counter S}
local D
D = {NewDictionary}
fun {StepCount St}
case St
of H|T then
if {Dictionary.member D H}
then {Dictionary.put D H {Dictionary.get D H}+1}
else {Dictionary.put D H 1}
end
{Dictionary.entries D}|{StepCount T}
else nil
end
end
in
thread {StepCount S} end
end
end
local InS X in X = {Counter InS} InS = a|b|a|c|_ {Delay 2000} {Browse X} end
declare X C
S = a|b|a|c|_
C = {NewCell S}
D = {NewDictionary}
if {Dictionary.member D @C.1} then
X = {Dictionary.get D @C.1}
{Dictionary.put D @C.1 X+1}
else
{Dictionary.put D @C.1 1}
end
{Browse {Dictionary.entries D}}
C := @C.2
if {Dictionary.member D @C.1} then
X = {Dictionary.get D @C.1}
{Dictionary.put D @C.1 X+1}
else
{Dictionary.put D @C.1 1}
end
{Browse {Dictionary.entries D}}
C := @C.2
if {Dictionary.member D @C.1} then
X = {Dictionary.get D @C.1}
{Dictionary.put D @C.1 X+1}
else
{Dictionary.put D @C.1 1}
end
{Browse {Dictionary.entries D}}