learning-sicp

My embarrassing half assed SICP run.
git clone https://kaka.farm/~git/learning-sicp
Log | Files | Refs

exercise-75.scm (563B)


      1 (define-library (sicp solutions chapter-2 exercise-75)
      2   (import (scheme base)
      3           (only (rnrs) cos sin)
      4           (sicp utils))
      5   (export
      6    make-from-mag-ang
      7    )
      8 
      9   (begin
     10     (define (make-from-mag-ang mag ang)
     11       (define (dispatch op)
     12         (cond
     13          ((eq? op 'real-part)
     14           (* mag
     15              (cos ang)))
     16          ((eq? op 'imag-part)
     17           (* mag
     18              (sin ang)))
     19          ((eq? op 'magnitude) mag)
     20          ((eq? op 'angle) ang)
     21          (else
     22           (error "Unknown op: make-from-mag-ang" op))))
     23 
     24       dispatch)))