0

Hey I am trying to write some scheme can you help me out here?

(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)

It gives me an error ;Syntactic keyword may not be used as an expression: #[keyword-value-item 13]

shinigaami25
  • 117
  • 1
  • 7

1 Answers1

3

A couple of parentheses are missing. This is the correct syntax for 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))))
Óscar López
  • 232,561
  • 37
  • 312
  • 386