forked from drspro/metta-wam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
key-lookups-many.metta
executable file
·84 lines (67 loc) · 1.63 KB
/
key-lookups-many.metta
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
; Initialize data space
!(bind! &data (new-space))
; Define new-entry! function
(= (new-entry! $key $value)
(let $new-state (new-state $value)
(add-atom &data (= (get-data $key) $new-state))
)
)
; Populate the data space with entries manually for size 10
!(new-entry! k-0 v-0)
!(new-entry! k-1 v-1)
!(new-entry! k-2 v-2)
!(new-entry! k-3 v-3)
!(new-entry! k-4 v-4)
!(new-entry! k-5 v-5)
!(new-entry! "k-6" v-6)
!(new-entry! k-7 v-7)
!(new-entry! k-8 v-8)
!(new-entry! k-9 v-9)
!(assertEqual
(let $v (new-state v-0)
(match &data (= (get-data $k) $v) $k))
k-0)
!(assertEqual
(let $v (new-state v-1)
(match &data (= (get-data $k) $v) $k))
k-1)
!(assertEqual
(let $v (new-state v-2)
(match &data (= (get-data $k) $v) $k))
k-2)
!(assertEqual
(let $v (new-state v-3)
(match &data (= (get-data $k) $v) $k))
k-3)
!(assertEqual
(let $v (new-state v-4)
(match &data (= (get-data $k) $v) $k))
k-4)
!(assertEqual
(let $v (new-state v-5)
(match &data (= (get-data $k) $v) $k))
k-5)
!(assertEqual
(let $v (new-state v-6)
(match &data (= (get-data $k) $v) $k))
"k-6")
!(assertEqual
(let $v (new-state v-7)
(match &data (= (get-data $k) $v) $k))
k-7)
!(assertEqual
(let $v (new-state v-8)
(match &data (= (get-data $k) $v) $k))
k-8)
!(assertEqual
(let $v (new-state v-9)
(match &data (= (get-data $k) $v) $k))
k-9)
!(assertEqual
(let $k k-1
(match &data (= (get-data $k) $v) (get-state $v)))
v-1)
!(assertEqual (get-state (match &data (= (get-data k-7) $v) $v))
v-7)
!(assertEqual (match &data (= (get-data k-7) $v) (get-state $v))
v-7)