Skip to content

Instantly share code, notes, and snippets.

@krv
Created January 29, 2013 20:11
Show Gist options
  • Save krv/4667329 to your computer and use it in GitHub Desktop.
Save krv/4667329 to your computer and use it in GitHub Desktop.
Wortels van vierkantsvergelijkingen oplossen, yay
(define (discriminant a b c)
(- (expt b 2) (* 4 a c)))
(define (wortel a b c)
(if (> (discriminant a b c) 0)
(list (/ (- (- b) (sqrt (discriminant a b c))) (* 2 a)) (/ (+ (- b) (sqrt (discriminant a b c))) (* 2 a)))
(if (= (discriminant a b c) 0)
(/ (- (- b)) (* 2 a))
"Imagine a solution")))
(define (vierkantsvgl a b c)
(wortel a b c))
(vierkantsvgl 1 1 1)
(vierkantsvgl 1 2 1)
(vierkantsvgl 1 5 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment