[add bernouilli to regression test
John Meacham <john@repetae.net>**20100726221331
 Ignore-this: 99bf0548bd83ac508d7151e737824ab7
] addfile ./regress/tests/9_nofib/bernouilli.expected.stdout
hunk ./regress/tests/9_nofib/bernouilli.expected.stdout 1
+Bernoulli of 10 is 5%66
addfile ./regress/tests/9_nofib/bernouilli.hs
hunk ./regress/tests/9_nofib/bernouilli.hs 1
+-- There was a lot of discussion about various ways of computing
+-- Bernouilli numbers (whatever they are) on haskell-cafe in March 2003
+-- Here's one of the programs.
+
+-- It's not a very good test, I suspect, because it manipulates big integers,
+-- and so probably spends most of its time in GMP.  
+
+import Ratio
+import System
+
+-- powers = [[r^n | r<-[2..]] | n<-1..]
+powers = [2..] : map (zipWith (*) (head powers)) powers
+
+-- powers = [[(-1)^r * r^n | r<-[2..]] | n<-1..]
+neg_powers = 
+  map (zipWith (\n x -> if n then x else -x) (iterate not True)) powers
+
+pascal:: [[Integer]]
+pascal = [1,2,1] : map (\line -> zipWith (+) (line++[0]) (0:line)) pascal
+
+bernoulli 0 = 1
+bernoulli 1 = -(1%2)	
+bernoulli n | odd n = 0
+bernoulli n = 
+   (-1)%2 
+     + sum [ fromIntegral ((sum $ zipWith (*) powers (tail $ tail combs)) - 
+                            fromIntegral k) %
+             fromIntegral (k+1)
+     | (k,combs)<- zip [2..n] pascal]
+  where powers = (neg_powers!!(n-1))
+
+main = do
+ [arg] <- getArgs
+ let n = (read arg)::Int
+ putStr $ "Bernoulli of " ++ (show n) ++ " is "
+ putStrLn . filter (\c -> not (c `elem` "( )")) . show . bernoulli $ n
hunk ./regress/tests/9_nofib/config.yaml 4
+  bernouilli:
+   args: 10