-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.scm
57 lines (53 loc) · 1.19 KB
/
test.scm
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
56
57
(import
(for (only (core)
define-syntax
quote
syntax
write)
run)
(for (only (core)
...
_
begin
generate-temporaries
identifier?
if
lambda
list
set!
syntax
syntax-case
~let)
expand))
(define-syntax let*
(lambda (x)
(syntax-case x ()
[(_ () b1 b2 ...) #'(begin b1 b2 ...)]
[(_ ((i1 e1) (i2 e2) ...) b1 b2 ...)
#'(~let (i1 e1) (let* ((i2 e2) ...) b1 b2 ...))])))
(define-syntax with-syntax
(lambda (x)
(syntax-case x ()
[(_ ((p r0) ...) r1 r2 ...)
#'(syntax-case (list r0 ...) ()
((p ...) (begin r1 r2 ...)))])))
(define-syntax asdxfsdfadfs
(lambda (x)
(syntax-case x ()
[(_ ((i e) ...) b1 b2 ...)
(with-syntax
([(t ...) (generate-temporaries #'(i ...))])
#'(let* ((i e) ...)
b1 b2 ...))])))
(write #'(t ... ... ... ...))
#|
(define-syntax and
(lambda (x)
(syntax-case x ()
[(_ ) #'#t]
[(_ e) #'e]
[(_ e1 e2 e3 ...)
#'(let* ([t ... e2])
(if t ... (and e2 e3 ...) t ...))])))
(write (and #t 'foo))
|#