|
|
@ -21,12 +21,12 @@ |
|
|
|
|
|
|
|
|
|
|
|
(define (id value) value) |
|
|
|
(define (id value) value) |
|
|
|
(define (is-not value) (lambda (x) (not (equal? x value)))) |
|
|
|
(define (is-not value) (lambda (x) (not (equal? x value)))) |
|
|
|
(define is-not-empty (lambda (x) (not (null? x)))) |
|
|
|
(define (is-not-empty value) (not (null? value))) |
|
|
|
|
|
|
|
|
|
|
|
(define (prepend first-value) (lambda (rest) (cons first-value rest))) |
|
|
|
(define (prepend first-value) (lambda (rest) (cons first-value rest))) |
|
|
|
|
|
|
|
|
|
|
|
(define Y (lambda (f) (f (lambda (x) ((Y f) x))))) |
|
|
|
(define (Y f) (f (lambda (x) ((Y f) x)))) |
|
|
|
(define Y2 (lambda (f) (f (lambda (x y) ((Y2 f) x y))))) |
|
|
|
(define (Y2 f) (f (lambda (x y) ((Y2 f) x y)))) |
|
|
|
|
|
|
|
|
|
|
|
(define (reduce-right reducer initial) (Y |
|
|
|
(define (reduce-right reducer initial) (Y |
|
|
|
(lambda (f) (lambda (values) |
|
|
|
(lambda (f) (lambda (values) |
|
|
@ -42,7 +42,7 @@ |
|
|
|
right) |
|
|
|
right) |
|
|
|
left)) |
|
|
|
left)) |
|
|
|
|
|
|
|
|
|
|
|
;=============== starts-with ====================== |
|
|
|
;=============== flat ====================== |
|
|
|
(define flat (reduce-right concat '())) |
|
|
|
(define flat (reduce-right concat '())) |
|
|
|
|
|
|
|
|
|
|
|
(assert-eq "flat test 1 failed" |
|
|
|
(assert-eq "flat test 1 failed" |
|
|
|