File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7474 [`(if ,e0 ,e1 ,e2) (append (λs e0) (λs e1) (λs e2))]
7575 [`(+ ,e0 ,e1) (append (λs e0) (λs e1))]
7676 [`(let ((,x ,e0)) ,e1) (append (λs e0) (λs e1))]
77- [`(letrec ,bs ,e0) (append (map second bs) (λs e0))]
77+ [`(letrec ,bs ,e0) (append (apply append ( map (compose λs second) bs) ) (λs e0))]
7878 [`(λ ,xs ,l ,e0) (cons e (λs e0))]
7979 [`(,e . ,es) (append (λs e) (apply append (map λs es)))]))
8080
Original file line number Diff line number Diff line change 8989 (+ n (tri (sub1 n)))))))
9090 10 ))
9191 56 )
92-
92+
93+ (check-equal?
94+ (run
95+ '(begin (define (map f ls)
96+ (if (empty? ls)
97+ '()
98+ (cons (f (car ls)) (map f (cdr ls)))))
99+
100+ (map (λ (f) (f 0 ))
101+ (cons (λ (x) (add1 x))
102+ (cons (λ (x) (sub1 x))
103+ '() )))))
104+ '(1 -1 ))
105+
106+ (check-equal?
107+ (run
108+ '(begin (define (map f ls)
109+ (letrec ((mapper (λ (ls)
110+ (if (empty? ls)
111+ '()
112+ (cons (f (car ls)) (mapper (cdr ls)))))))
113+ (mapper ls)))
114+ (map (λ (f) (f 0 ))
115+ (cons (λ (x) (add1 x))
116+ (cons (λ (x) (sub1 x))
117+ '() )))))
118+ '(1 -1 ))
119+
120+ (check-equal?
121+ (run
122+ '(begin (define (map f ls)
123+ (begin (define (mapper ls)
124+ (if (empty? ls)
125+ '()
126+ (cons (f (car ls)) (mapper (cdr ls)))))
127+ (mapper ls)))
128+ (map (λ (f) (f 0 ))
129+ (cons (λ (x) (add1 x))
130+ (cons (λ (x) (sub1 x))
131+ '() )))))
132+ '(1 -1 ))
93133
You can’t perform that action at this time.
0 commit comments