-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathif.robin
42 lines (27 loc) · 964 Bytes
/
if.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
;'<<SPEC'
### `if` ###
-> Tests for functionality "Evaluate core Robin Expression"
`if` evaluates its first argument to a boolean value. If that value is
`#t`, it evaluates, and evaluates to, its second argument; or if that value
is `#f` it evaluates, and evaluates to, its third argument. In all cases,
at most two arguments are evaluated.
| (if #t 7 9)
= 7
| (if #f 7 9)
= 9
The identifiers named in the branch which is not evaluated need not be
properly bound to values in the environment.
| (if #t 1 (prepend fred ethel))
= 1
The second and third arguments can be arbitrary expressions, but `if`
expects its first argument to be a boolean.
| (if 5 7 9)
? abort (expected-boolean 5)
`if` expects exactly three arguments.
| (if #t 7)
? abort (illegal-arguments (#t 7))
| (if #t 7 8 9)
? abort (illegal-arguments (#t 7 8 9))
`if` is basically equivalent to Scheme's `if`.
'<<SPEC'
(require if)