-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlist.robin
44 lines (30 loc) · 1.1 KB
/
list.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
;'<<SPEC'
-> Tests for functionality "Evaluate Robin Expression (with literal and bind and list)"
`list` is an operator which evaluates each of its arguments, and evaluates to a
(proper) list containing each of the results, in the same order.
| (list 1 2 3 4 5)
= (1 2 3 4 5)
| (list (list 2 3) (list 6 7) (list (subtract 9 1) 9))
= ((2 3) (6 7) (8 9))
`list` need not have any arguments at all; the result is the empty list.
| (list)
= ()
Unlike `literal`, `list` does evaluate its arguments, all of them.
| (list (literal x) (literal y))
= (x y)
Attempting to construct a list containing an `abort` value will produce an
`abort` value.
| (list (literal x) (abort 999))
? abort 999
| (list (abort 999) (literal x))
? abort 999
'<<SPEC'
(define list (fexpr (args env)
(bind list-r (fexpr (iargs ienv)
(bind self (eval ienv (head iargs))
(bind items (eval ienv (head (tail iargs)))
(if (equal? items ())
()
(prepend (eval env (head items))
(self self (tail items)))))))
(list-r list-r args))))