(define (complex-num x y)
(cons x y))
(define (real x)
(car x))
(define (imag x)
(cdr x))
对吗?或者,也许您可以建议一种更好的方法。
答案 0 :(得分:1)
Yes, that's a correct way to represent complex numbers in Scheme. It's also possible to alias the procedures, because you're calling them directly:
(define complex-num cons)
(define real car)
(define imag cdr)
... But it's a matter of taste, and anyway your solution is easier to understand.