Faulhaber's formula: Difference between revisions
Content deleted Content added
m added a Wiki reference. |
m →Bernouilli polynomials: (Tidying) |
||
Line 899:
import Data.Char (isSpace)
import Data.Monoid ((<>))
import Data.Bool (bool)
-- FAULHABER
faulhaber :: [[Rational]]
faulhaber =
Line 911 ⟶ 912:
[0 ..]
-- EXPRESSION STRINGS
polynomials :: [[(String, String)]]
polynomials = fmap ((ratioPower =<<) . reverse . flip zip [1 ..]) faulhaber
Line 943 ⟶ 944:
| otherwise = intercalate "/" [show num, show den]
s = sr <> sn
in
-- Rows of uneven length -> All rows padded to length of longest
Line 963 ⟶ 962:
, " -> "
, foldr
(\s a -> concat [s, bool " + " " " (blank a || head a == '-'), a])
(polyTerm <$> row)
]
Line 997 ⟶ 989:
unsignedLength xs =
let l = length xs
in bool (bool l (l - 1) ('-' == head xs)) 0 (0 == l)
-- TEST
main :: IO ()
main = (putStrLn . unlines . expressionTable . take 10) polynomials</lang>
|