0
votes

I have such a code, I've checked my braces, but still have no clue why the compiler gives me

#f is not a function [sumOfSqaresOfTwoBiggest, (anon)]

error

(
  define (sumOfSqaresOfTwoBiggest a b c) (
    cond (
      ((and (> a c ) (> b c)) (+ (* a a) (* b b)))
      ((and (> a b) (> c b)) (+ (* a a) (* c c)))
      (else (+ (* a a) (* c c)))
    )
  )
)
(sumOfSqaresOfTwoBiggest 1 2 3)
1
a good idea would be to use standard Lisp formatting and not inventing your own. Thus you will not train to recognize standard Lisp construct formatting. Especially C-like formatting will be misleading. Lisp is not structure like C code. - Rainer Joswig
For a clue about your problem: count the parentheses after COND. How many are there and is that correct? - Rainer Joswig

1 Answers

1
votes

You have a rather unusual way of formatting lisp code. In fact, using an editor tailored for this kind of code will help you a lot to avoid this kind of errors, which is, yes, a wrong parenthesis.

Here is a correct version with the usual indentation:

(define (sumOfSqaresOfTwoBiggest a b c)
  (cond ((and (> a c ) (> b c)) (+ (* a a) (* b b)))
        ((and (> a b) (> c b)) (+ (* a a) (* c c)))
        (else (+ (* a a) (* c c)))))

(sumOfSqaresOfTwoBiggest 1 2 3)