RosettaCodeData/Task/Polynomial-long-division/Haskell/polynomial-long-division-2.hs
Ingy döt Net b83f433714 tasks a-s
2013-04-10 23:57:08 -07:00

11 lines
365 B
Haskell

str_poly l = intercalate " + " $ terms l
where term v 0 = show v
term 1 1 = "x"
term v 1 = (show v) ++ "x"
term 1 p = "x^" ++ (show p)
term v p = (show v) ++ "x^" ++ (show p)
terms :: Fractional a => [a] -> [String]
terms [] = []
terms (0:t) = terms t
terms (h:t) = (term h (length t)) : (terms t)