module Main where import Bell import Matchings import Stirling import Control.Monad heightOfDistinctAtoms :: Int -> Integer heightOfDistinctAtoms n = toInteger $ n + 1 heightOfAtoms :: Int -> Integer heightOfAtoms n = sum [ norbits k * heightOfDistinctAtoms k | k <- [0 .. n] ] + sum [ matchings o1 o2 | (o1, o2) <- cross ] where norbits k = secondStirling n k orbits k = replicate (fromIntegral (norbits k)) k allOrbits = concat [ orbits k | k <- [0..n] ] cross = [ (allOrbits !! i, allOrbits !! j) | let m = length allOrbits, i <- [0 .. m-1], j <- [i+1 .. m-1] ] orbitsOf :: Int -> [Int] orbitsOf n = concat [ replicate (fromIntegral (secondStirling n k)) k | k <- [0..n] ] main :: IO () main = do let out = [ (i, heightOfAtoms i, bell (2*i)) | i <- [0..10] ] forM_ out $ \(i, n, b) -> putStrLn ("h(A^" ++ show i ++ ") = " ++ show n ++ " < B_" ++ show (2*i) ++ " = " ++ show b)