We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3a5b061 commit e890a56Copy full SHA for e890a56
2.75.scm
@@ -0,0 +1,22 @@
1
+(define (apply-generic op arg) (arg op))
2
+
3
+(define (make-from-real-imag x y)
4
+ (define (dispatch op)
5
+ (cond ((eq? op 'real-part) x)
6
+ ((eq? op 'imag-part) y)
7
+ ((eq? op 'magnitude)
8
+ (sqrt (+ (square x) (square y))))
9
+ ((eq? op 'angle) (atan y x))
10
+ (else
11
+ (error "Unknown op:
12
+ MAKE-FROM-REAL-IMAG" op))))
13
+ dispatch)
14
15
+(define (make-from-mag-ang r a)
16
17
+ (cond ((eq? op 'real-part) (* r (cos a)))
18
+ ((eq? op 'imag-part) (* r (sin a)))
19
+ ((eq? op 'magnitude) r)
20
+ ((eq? op 'angle) a)
21
+ (else (error "Unknown op: MAKE-FROM-REAL-IMAG" op))))
22
0 commit comments