Guest User

QuadraticSolver

a guest
May 4th, 2012
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 0.34 KB | None | 0 0
  1. (define (quad a b c)
  2.   (if (< (- (square b) (* 4 a c)) 0) 'imaginary)
  3.               ;;;Computes positive root, then negative root, and appends it all to the list
  4.   (else (cons (/ (+ (* -1 b) (sqrt (- (square b) (* 4 a c))) (* 2 a)))
  5.               (cons (/ (- (* -1 b) (sqrt (- (square b) (* 4 a c))) (* 2 a))) '())
  6.              
  7.         ))
  8.   )
Advertisement
Add Comment
Please, Sign In to add comment