-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-p19.soar
70 lines (65 loc) · 1.5 KB
/
test-p19.soar
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
# rotate a list N places to the left
setup {
source "common.soar"
sp {p19*propose*slice*first
(state <s> ^name p19
-^first
^head <head>
^N <n>)
-->
(<s> ^operator <o>)
(<o> ^name bebot*list*slice
^head <head>
^end <n>
^return-to first)
}
sp {p19*propose*slice*second
(state <s> ^name p19
^first
-^second
^head <head>
^N <n>)
-->
(<s> ^operator <o>)
(<o> ^name bebot*list*slice
^head <head>
^start <n>
^return-to second)
}
sp {p19*propose*append
(state <s> ^name p19
^first <first>
^second <second>
-^result)
-->
(<s> ^operator <o>)
(<o> ^name bebot*list*append
^first <second>
^second <first>
^return-to result)
}
}
test "P19: Rotate a list N places to the left" {
sp {apply*init
(state <s> ^operator.name init)
-->
(<s> ^name p19
^head (list 1 2 3 4 5 6 7 8 9)
^N 3)
}
sp {succeeded
(state <s> ^name p19
^result <result>)
(<result> ^value 4 ^next <n0>)
(<n0> ^value 5 ^next <n1>)
(<n1> ^value 6 ^next <n2>)
(<n2> ^value 7 ^next <n3>)
(<n3> ^value 8 ^next <n4>)
(<n4> ^value 9 ^next <n5>)
(<n5> ^value 1 ^next <n6>)
(<n6> ^value 2 ^next <n7>)
(<n7> ^value 3 ^next nil)
-->
(pass)
}
}