I am a self-taught software engineer who is trying to fill in their CS knowledge gaps by following the SICP book which comes highly recommended. I'm having trouble with one of the first exercises and I'm pretty sure it's a syntax problem, but I can't figure it out.
Exercise 1.3: Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers.
#lang sicp
(define (square x) (* x x))
(define (squaresum x y) (+ (square x) (square y)))
(define
(squaresumlg x y z)
(cond
(and (> x z) (> y z)) (squaresum x y)
(and (> x y) (> z y)) (squaresum x z)
(and (> y x) (> z x)) (squaresum y z)))
(squaresumlg 1 2 3)
To run this I am using DrRacket with the 'sicp' package. The and
expressions run just fine on their own, but inside the cond
expression, I receive the error:
and: bad syntax in: and
Can someone please tell me where I've gone wrong in my program? If you have any tips on how I could do this more efficiently please let me know.