git @ Cat's Eye Technologies Robin / bebe382
Fix remaining Reactor usage in example programs. Chris Pressey 5 years ago
3 changed file(s) with 41 addition(s) and 37 deletion(s). Raw diff Collapse all Expand all
0 ;''FIXME -- uses old (Robin 0.2) Reactor syntax, not expected to work under 0.3''
1
2 ;(require small list arith)
0 ;''Requires stdlib.''
31
42 (reactor (line-terminal) (list 0 0) (macro (self args env)
53 (let ((event (head args))
6 (payload (head (tail args)))
7 (state (head (tail (tail args))))
4 (event-type (head event))
5 (event-payload (head (tail event)))
6 (state (head (tail args)))
87 (x (head state))
98 (y (head (tail state)))
109 (move (fun (msg dx dy state)
2120 (list state (list (literal writeln)
2221 (literal ''Please enter n, s, e, or w, or q to quit.''))))))
2322 (choose
24 ((equal? event (literal init))
23 ((equal? event-type (literal init))
2524 (list state (list (literal writeln)
2625 (literal ''Welcome to Not Quite an Adventure!''))))
27 ((equal? event (literal eof))
26 ((equal? event-type (literal eof))
2827 (list state (list (literal writeln)
2928 (literal ''Bye!''))))
30 ((equal? event (literal readln))
31 (if (empty? payload)
29 ((equal? event-type (literal readln))
30 (if (empty? event-payload)
3231 (dont-understand state)
33 (bind letter (list (head payload))
32 (bind letter (list (head event-payload))
3433 (choose
3534 ((equal? letter (literal ''n''))
3635 (move (literal ''North!'') 0 1 state))
4140 ((equal? letter (literal ''w''))
4241 (move (literal ''West!'') (subtract 0 1) 0 state))
4342 ((equal? letter (literal ''q''))
44 (list state (list (literal close) 0)))
43 (list state (list (literal stop) 0)))
4544 (else
4645 (dont-understand state))))))
4746 (else
0 ;''FIXME -- uses old (Robin 0.2) Reactor syntax, not expected to work under 0.3''
1
2 (reactor (line-terminal) 0 (macro (self args env)
3 (bind event (head args)
4 (bind payload (head (tail args))
5 (if (equal? event (literal readln))
6 (list 0 (list (literal writeln) payload))
7 (list 0))))))
0 (reactor (line-terminal) 0
1 (macro (self args env)
2 (bind event (head args)
3 (bind event-type (head event)
4 (bind event-payload (head (tail event))
5 (if (equal? event-type (literal readln))
6 (list 0
7 (list (literal writeln) event-payload))
8 (list 0)))))))
0 ;''FIXME -- uses old (Robin 0.2) Reactor syntax, not expected to work under 0.3''
1
2 (define inc (fun (a) (subtract a (subtract 0 1))))
3 (reactor (line-terminal) 0 (macro (self args env)
4 (bind event (head args)
5 (bind payload (head (tail args))
6 (if (equal? event (literal readln))
7 (list 0 (list (literal writeln) payload))
8 (list 0))))))
9 (reactor (line-terminal) 65 (macro (self args env)
10 (bind event (head args)
11 (bind payload (head (tail args))
12 (bind state (head (tail (tail args)))
13 (if (equal? state 67)
14 (list state (list (literal close) 0))
15 (if (equal? event (literal readln))
16 (list (inc state) (list (literal writeln) (list state)))
17 (list state))))))))
0 (define inc (macro (self args env)
1 (subtract (eval env (head args)) (subtract 0 1))))
2 (reactor (line-terminal) 65
3 (macro (self args env)
4 (bind state (head (tail args))
5 (bind event (head args)
6 (bind event-type (head event)
7 (bind event-payload (head (tail event))
8 (if (equal? event-type (literal readln))
9 (if (equal? state 68)
10 (list state (list (literal stop) 0))
11 (list (inc state) (list (literal writeln) event-payload)))
12 (list state))))))))
13 (reactor (line-terminal) 65
14 (macro (self args env)
15 (bind state (head (tail args))
16 (bind event (head args)
17 (bind event-type (head event)
18 (bind event-payload (head (tail event))
19 (if (equal? event-type (literal readln))
20 (list (inc state) (list (literal writeln) (list state)))
21 (list state))))))))