SICP Ex 1.3 错误;句法关键字不能用作表达式:#[keyword-value-item 13]
SICP Ex 1.3 error ;Syntactic keyword may not be used as an expression: #[keyword-value-item 13]
嘿,我正在尝试编写一些方案,你能帮我吗?
(define (square a b) (+ (* a a) (* b b)))
(define (sumsq x y z)
(cond (and (< x y) (< x z) (square y z))
(and (< y x) (< y z) (square x z))
(else (square y z))))
(sumsq 1 2 3)
它给我一个错误;Syntactic keyword may not be used as an expression: #[keyword-value-item 13]
少了几个括号。这是 cond
:
的正确语法
(define (sumsq x y z)
(cond ((and (< x y) (< x z)) (square y z))
((and (< y x) (< y z)) (square x z))
(else (square y z))))
嘿,我正在尝试编写一些方案,你能帮我吗?
(define (square a b) (+ (* a a) (* b b)))
(define (sumsq x y z)
(cond (and (< x y) (< x z) (square y z))
(and (< y x) (< y z) (square x z))
(else (square y z))))
(sumsq 1 2 3)
它给我一个错误;Syntactic keyword may not be used as an expression: #[keyword-value-item 13]
少了几个括号。这是 cond
:
(define (sumsq x y z)
(cond ((and (< x y) (< x z)) (square y z))
((and (< y x) (< y z)) (square x z))
(else (square y z))))