-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeature_demo.clj
229 lines (212 loc) · 9.37 KB
/
feature_demo.clj
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
(use 'jursey.repl-ui)
(require '[jursey.transcriptor-tools :refer [check-diff!]])
;; This file contains verbose data structures. Please concentrate on the parts
;; indicated by arrows (↑↓) and comments. I hope you won't be too confused.
;; If you want to see the intermediate workspaces, please run the commands in
;; the REPL by yourself.
(defn base-scenario []
(reset)
(ask-root "Approx. how many [Rubik's Cubes] fit in a [Buc-ee's]?")
(start-working)
(ask "What is the outside volume of $q.3?")
(ask "What is the inside volume of $q.3?")
(unlock "sq.0.a")
(unlock "q.1")
(reply (format "%s cm³" (* 5.7 5.7 5.7)))
(unlock "r")
(unlock "r.3")
(unlock "r.3.children.0"))
;;;; Children
(base-scenario)
(check-diff!
{"q" "Approx. how many $1 fit in a $3?",
"sq" {"0" {"q" "What is the outside volume of $q.1?", "a" "185.193 cm³"},
"1" {"q" "What is the inside volume of $q.3?", "a" :locked}},
"r" {:max-v 6,
"3" {"ws" {"q" "Approx. how many $1 fit in a $3?",
"sq" {"0" {"q" "What is the outside volume of $q.1?",
"a" "185.193 cm³"},
"1" {"q" "What is the inside volume of $q.3?",
"a" :locked}},
"r" :locked},
"children" {"0" {:max-v 1, "parent" :locked}, "1" :locked},
;; ↑ ↑
;; One entry for each sub-question.
"act" [:unlock "r"]}}})
;;;; Latest version / Reflection of reflection
(base-scenario)
(unlock "r.6")
(check-diff!
{"q" "Approx. how many $1 fit in a $3?",
"sq" {"0" {"q" "What is the outside volume of $q.1?", "a" "185.193 cm³"},
"1" {"q" "What is the inside volume of $q.3?", "a" :locked}},
"r" {:max-v 7,
;; ↑
;; In the top-level workspace one can access everything up to the
;; previous version.
"3" {"ws" {"q" "Approx. how many $1 fit in a $3?",
"sq" {"0" {"q" "What is the outside volume of $q.1?",
"a" "185.193 cm³"},
"1" {"q" "What is the inside volume of $q.3?",
"a" :locked}},
"r" :locked},
"children" {"0" {:max-v 1, "parent" :locked}, "1" :locked},
"act" [:unlock "r"]},
"6" {"ws" {"q" "Approx. how many $1 fit in a $3?",
"sq" {"0" {"q" "What is the outside volume of $q.1?",
"a" "185.193 cm³"},
"1" {"q" "What is the inside volume of $q.3?",
"a" :locked}},
;; If one of the earlier versions contained reflection, it
;; will be reflected, too.
;; ↓
"r" {:max-v 6,
"3" {"ws" {"q" "Approx. how many $1 fit in a $3?",
"sq" {"0" {"q" "What is the outside volume of $q.1?",
"a" "185.193 cm³"},
"1" {"q" "What is the inside volume of $q.3?",
"a" :locked}},
"r" :locked},
"children" {"0" {:max-v 1, "parent" :locked},
"1" :locked},
"act" [:unlock "r"]}}},
"children" {"0" :locked, "1" :locked},
"act" [:unlock "r.6"]}}})
;;;; Children's versions
(base-scenario)
(unlock "r.3.children.0.0")
(unlock "r.3.children.0.1")
(check-diff!
{"q" "Approx. how many $1 fit in a $3?",
"sq" {"0" {"q" "What is the outside volume of $q.1?", "a" "185.193 cm³"},
"1" {"q" "What is the inside volume of $q.3?", "a" :locked}},
"r" {:max-v 8,
"3" {"ws" {"q" "Approx. how many $1 fit in a $3?",
"sq" {"0" {"q" "What is the outside volume of $q.1?",
"a" "185.193 cm³"},
"1" {"q" "What is the inside volume of $q.3?",
"a" :locked}},
"r" :locked},
"children" {"0" {:max-v 1,
"parent" :locked,
;; One can inspect each version of a descendant,
;; ↓
"0" {"ws" {"q" "What is the outside volume of $1?",
"sq" {},
"r" :locked},
"children" {},
;; including what action the user took there.
;; ↓
"act" [:unlock "q.1"]},
;; ↓
"1" {"ws" {"q" "What is the outside volume of [1: Rubik's Cubes]?",
"sq" {},
"r" :locked},
"children" {},
;; ↓
"act" [:reply "185.193 cm³"]}},
"1" :locked},
"act" [:unlock "r"]}}})
;;;; Parent
(base-scenario)
(unlock "r.3.children.0.parent")
(unlock "r.3.children.0.parent.0")
(check-diff!
{"q" "Approx. how many $1 fit in a $3?",
"sq" {"0" {"q" "What is the outside volume of $q.1?", "a" "185.193 cm³"},
"1" {"q" "What is the inside volume of $q.3?", "a" :locked}},
;; This workspace has no parent, because it is a root workspace.
;; ↓
"r" {:max-v 8,
"3" {"ws" {"q" "Approx. how many $1 fit in a $3?",
"sq" {"0" {"q" "What is the outside volume of $q.1?",
"a" "185.193 cm³"},
"1" {"q" "What is the inside volume of $q.3?",
"a" :locked}},
"r" :locked},
"children" {"0" {:max-v 1,
;; One can go up the tree, too, but not forward in
;; time. In this example, one can only reach the
;; versions of the parent that came before
;; sub-question 0 was asked.
;; ↓
"parent" {:max-v 0,
"0" {"ws" {"q" "Approx. how many $1 fit in a $3?",
"sq" {},
"r" :locked},
"children" {},
"act" [:ask
"What is the outside volume of $q.1?"]}}},
"1" :locked},
"act" [:unlock "r"]}}})
;;;; Reflection pointer in hypertext / Unlocking reflected pointers
(base-scenario)
(ask "Have a look at $r and $r.3 and tell me your impression.")
(unlock "sq.2.a")
(unlock "q.1")
(check-diff!
;; Reflection structures can be included in hypertext, too.
;; ↓
{"q" "Have a look at [1: \n{:max-v 6}\n] and $3 and tell me your impression.",
;; ↑
;; Note that one doesn't get the whole structure that you saw in the
;; parent, but only the small part that the pointer points at. One can
;; explore from there.
"sq" {},
"r" :locked})
(unlock "q.1.2")
(comment
{"q" "Have a look at [1:
{:max-v 6,
;; ↑
;; Reflection structures in hypertext can only reach backwards from the
;; time when the hypertext was created.
“2”
{“ws”
{“q” “Approx. how many $1 fit in a $3?”,
;; ↑
;; Reflected structures are snapshots of the past. Therefore, one cannot
;; unlock a reflected pointer. But one can still point at it and
;; ‘launder’ it through a sub-question. See below.
“sq”
{“0” {“q” “What is the outside volume of $q.1?”, “a” :locked},
“1” {“q” “What is the inside volume of $q.3?”, “a” :locked}},
“r” :locked},
“children” {“0” :locked, “1” :locked},
“act” [:unlock “sq.0.a”]}}
] and $3 and tell me your impression.",
"sq" {},
"r" :locked})
(ask "Give me $q.1.2.ws.q.1.")
(unlock "sq.0.a")
(reply "$q.1")
(unlock "sq.0.a.0")
(comment
{…
"sq" {"0" {"q" "Give me $q.1.2.ws.q.0.", "a" "[1: Rubik's Cubes]"}},
"r" :locked})
;;;; Reflection pointer in root reply
(base-scenario)
(reply "I have one good child $r.3.children.0.1 and one bad $r.3.children.1")
(get-root-qas)
(comment
(["Approx. how many [1: Rubik's Cubes] fit in a [3: Buc-ee's]?"
"I have one good child [0:
;; When you pass a pointer to a version, the surrounding structure will
;; be included.
;; ↓
{:max-v 1,
“parent” :locked,
“1”
{“ws”
{“q” “What is the outside volume of [0: Rubik's Cubes]?”,
“sq” {},
;; Unlike normal pointers in a root reply, pointers inside a
;; reflection structure won't be unlocked automatically.
;; ↓
“r” :locked},
“children” {},
“act” [:reply “185.193 cm³”]}}
] and one bad [1:
{:max-v 0, “parent” :locked}
]"]))