views:

94

answers:

1
(define (square x)
  (display (* x x)))

(define (sum-of-squares a b) 
  (+ (square a) (square b)))

I tested it, and the sum-of-squares function will not work. Why is this?

+7  A: 

(display x) evaluates to void (could be seen as nothing). It is a function call that prints out the argument but doesn't return it. Instead you should define the square function to evaluate the value without displaying, that is:

(define (square x)
  (* x x))
Touko