-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathor.robin
46 lines (30 loc) · 871 Bytes
/
or.robin
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
;'<<SPEC'
-> Tests for functionality "Evaluate Robin Expression (with Boolean)"
`or` evaluates both of its arguments to booleans, and evaluates to the
logical disjunction (boolean "or") of these two values.
| (or #t #t)
= #t
| (or #t #f)
= #t
| (or #f #t)
= #t
| (or #f #f)
= #f
`or` expects exactly two arguments.
| (or #f)
? abort
| (or #t #f #f)
? abort (illegal-arguments
`or` expects both of its arguments to be booleans.
| (or 100 #f)
? abort (expected-boolean 100)
| (or #f 99)
? abort (expected-boolean 99)
`or` is short-circuiting in the sense that no arguments after the first
`#t` argument will be evaluated. Fully testing this requires side-effects,
but it can be demonstrated as follows.
| (or #t 100)
= #t
'<<SPEC'
(define or (fun (a b)
(if a #t (if b #t #f))))