There are several mistakes in the code:
- Some parentheses are incorrectly placed, use a good IDE to detect such problems. This is causing the error reported, the
let
doesn't have a body - You forgot to multiply in the
4ac
part - You're incorrectly accessing the second element in the list
- The
else
part must not have a condition - The output list is not correctly constructed
This should fix the errors, now replace null
with the actual call to the function that calculates the roots for the second and third cases (the (< d 0)
case is fine as it is):
(define roots-2
(lambda (L)
(let ((d (- (* (cadr L) (cadr L)) (* 4 (car L) (caddr L)))))
(cond ((< d 0) (list 0 null))
((= d 0) (list 1 null))
(else (list 2 null))))))