|
Begginer question: msg#00050lang.haskell.cafe
Hi, When compiling this: ************ import Complex; complex_root :: (Float, Float, Float) -> (Complex Float, Complex Float) complex_root (a,b,c) = (x1,x2) where { delta = b * b - 4 * a * c :: Float; sqr_delta = if delta >= 0 then (sqrt delta) :+ 0 else 0 :+ (sqrt delta) :: (Complex Float); x1 = (b + sqr_delta)/(2 * a); x2 = (b - sqr_delta)/(2 * a); } *********** I get this error message: ********** Couldn't match `Float' against `Complex Float' Expected type: Float Inferred type: Complex Float In the second argument of `(+)', namely `sqr_delta' In the definition of `x1': x1 = (b + sqr_delta) *********** Can you help me finding what is wrong? Shouldn't "b" be converted to Complex Float and be summed to sqr_delta? Thanks for your help, Maurício |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Initial (term) algebra for a state monad: 00050, ajb |
|---|---|
| Next by Date: | Re: Initial (term) algebra for a state monad: 00050, Ashley Yakeley |
| Previous by Thread: | Tutorial for server programming in concurrent Haskelli: 00050, Ahn Ki-yung |
| Next by Thread: | Re: Begginer question: 00050, Jules Bean |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |