Anonymous user
Cyclotomic polynomial: Difference between revisions
→{{header|Haskell}}: fixed pretty printing
(→{{header|Haskell}}: added solution) |
(→{{header|Haskell}}: fixed pretty printing) |
||
Line 1,896:
The task solution
<lang haskell>showPoly
showPoly p = foldl1 (\r -> (r ++) . term) $
dropWhile null $
foldMap (\(c, n) -> [show c ++ expt n]) $
zip (reverse p) [0..]
where
(1, i) -> " + " ++ "x^" ++ show i▼
term =
'1':'*':t -> " + " ++ t
'-':t -> " - " ++ t
main = do
|