-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathequal-p.robin
53 lines (35 loc) · 1.06 KB
/
equal-p.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
47
48
49
50
51
52
53
;'<<SPEC'
### `equal?` ###
-> Tests for functionality "Evaluate Robin Expression (with literal)"
`equal?` evaluates both of its arguments to arbitrary S-expressions
and compares them for deep equality.
`equal?` works on symbols.
| (equal?
| (literal this-symbol)
| (literal this-symbol))
= #t
| (equal?
| (literal this-symbol)
| (literal that-symbol))
= #f
`equal?` works on lists.
| (equal? (prepend 1 (prepend 2 (prepend 3 ())))
| (prepend 1 (prepend 2 (prepend 3 ()))))
= #t
`equal?` works on lists, deeply.
| (equal? (prepend 1 (prepend 2 (prepend 7 ())))
| (prepend 1 (prepend 2 (prepend 3 ()))))
= #f
Two values of different types are never equal.
| (equal? #t (prepend (literal a) ()))
= #f
| (equal? #f ())
= #f
Arguments to `equal?` can be any type, but fewer than or more than
two arguments will produce an abort value.
| (equal? 7)
? abort (illegal-arguments (7))
| (equal? 7 8 9)
? abort (illegal-arguments (7 8 9))
'<<SPEC'
(require equal?)