Skip to content

Instantly share code, notes, and snippets.

@yakreved
Created August 30, 2013 23:04
Show Gist options
  • Save yakreved/6395132 to your computer and use it in GitHub Desktop.
Save yakreved/6395132 to your computer and use it in GitHub Desktop.
sicp 2.75
(define (make-from-mag-ang r a)
(define (dispatch op)
(cond ((eq? op 'real-part) (* r (cos a)))
((eq? op 'imag-part) (* r (sin a)))
((eq? op 'magnitude) r)
((eq? op 'angle) a)
(else
(eror "Unknown op -- MAKE-FROM-MAG-ANG" op))))
dispatch)
((make-from-mag-ang 10 5) 'real-part)
((make-from-mag-ang 10 5) 'imag-part)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment