Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'          cps2-cps.scm - The same functions programmed in continuation passing style.Lecture 3 - slide 33 : 43
Program 3

; (define (w a b)     (f (g a) (h b) (g b) (h a)))
; (define (f a b c d) (+ a b c d))
; (define (g a)       (* a a))
; (define (h a)       (* a a a))

(define (w a b k0)
  (g a (lambda(v1)
         (h b (lambda (v2)
                (g b (lambda (v3)
                       (h a (lambda (v4)
                              (f v1 v2 v3 v4 k0))))))))))

(define (f a b c d k)
  (k (+ a b c d)))

(define (g a k)
  (k (* a a)))

(define (h a k)
  (k (* a a a)))