Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (combine-2 pred? bin un zero exc)
- (call/cc
- (lambda (exit)
- (letrec
- ((f (lambda (xs)
- (if (empty? xs)
- zero
- (if (pred? (first xs))
- (exit exc)
- (bin (first xs) (f (rest xs))))))))
- f))))
- (define product
- (combine zero?
- (trace *)
- id
- 1
- 0))
- (product '(1 2 3 4)
- ; 24
- (product '(1 4 8 2 3 9 0 2 3 0))
- ; define-values: assignment disallowed;
- ; cannot re-define a constant
- ; constant: product
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement