-
Notifications
You must be signed in to change notification settings - Fork 4
/
shen-tests.shen
56 lines (40 loc) · 882 Bytes
/
shen-tests.shen
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
54
55
#lang shen
(define max
X Y -> X where (> X Y)
_ Y -> Y)
(define test-2
4 4 5 <- (fail-if (= 2) 2)
4 4 X -> [success: X])
(define test-3
X -> (let Y (+ 1 (log 2))
(+ Y X)))
(define test-4
4 4 X <- (fail-if (= 2) X)
1 4 5 -> fail
4 4 X -> (* X X))
(define test-5
X Y -> (X Y))
(define test-6
X -> Y)
(define second
[_ Y | _] -> Y)
(define identity
X -> X)
(defmacro max-macro
[max X Y Z | W] -> [max X [max Y Z | W]])
(defmacro add1-macro
[add1-ct X] -> (let Y [+ X 1]
[identity Y]))
(define my-head
[X | Y] -> X
[] -> (error "head: empty list"))
(defmacro log-macro
[log N] -> [+ N 1])
(package math [abs]
(define abs
X -> (- X) where (< X 0)
X -> X))
(define foo
X -> (prolog? (return (+ (receive X) (receive X)))))
(define foo-2
X -> (prolog? (f (receive X) (h (g (receive X) X) (g Y)))))