Exercise 5.1.4: (back)
;; what-kind : number number number -> symbol
;; Examples: (what-kind 1 0 -1) -> 'two
;; Examples: (what-kind 2 4 2) -> 'one
;; Examples: (what-kind 3 2 1) -> 'none
;; Examples: (what-kind 0 1 2) -> 'degenerate
(define (what-kind a b c)
(cond
[(= a 0) 'degenerate]
[(> (square b) (* 4 a c)) 'two]
[(= (square b) (* 4 a c)) 'one]
[(< (square b) (* 4 a c)) 'none]))
;; square : number -> number
(define (square x) (* x x))
;; Tests
> (what-kind 1 2 3)
'none
> (symbol=? (what-kind 1 2 3) 'none)
true
> (what-kind 2 4 2)
'one
> (symbol=? (what-kind 2 4 2) 'one)
true
> (what-kind 1 0 -1)
'two
> (symbol=? (what-kind 1 0 -1) 'two)
true
> (what-kind 0 1 2)
'degenerate
> (symbol=? (what-kind 0 1 2) 'degenerate)
true