[plt-scheme] Re: CPS conversion example, question
On Jan 9, 2008 3:46 PM, Grant Rettke <grettke at acm.org> wrote:
> Is that the right way to do it?
I actually skipped a transformation in the end, so this is what it
should have been:
;; Let style
(define (pyth-ls x y k)
(let ([x2 (* x x)])
(let ([y2 (* y y)])
(let ([x2py2 (+ x2 y2)])
(let ([result (sqrt x2py2)])
(k result))))))
; CPS Style
(define (pyth-cps x y k)
((λ (x2)
((λ (y2)
((λ (x2py2)
((λ (result)
(k result)) (sqrt x2py2))) (+ x2 y2))) (* y y))) (* x x)))