module Math.Combinat.Tuples where
import Math.Combinat.Helper
tuples' :: [Int] -> [[Int]]
tuples' [] = [[]]
tuples' (s:ss) = [ x:xs | x <- [0..s] , xs <- tuples' ss ]
tuples1' :: [Int] -> [[Int]]
tuples1' [] = [[]]
tuples1' (s:ss) = [ x:xs | x <- [1..s] , xs <- tuples1' ss ]
countTuples' :: [Int] -> Integer
countTuples' shape = product $ map f shape where
f k = 1 + fromIntegral k
countTuples1' :: [Int] -> Integer
countTuples1' shape = product $ map fromIntegral shape
tuples
:: Int
-> Int
-> [[Int]]
tuples len k = tuples' (replicate len k)
tuples1
:: Int
-> Int
-> [[Int]]
tuples1 len k = tuples1' (replicate len k)
countTuples :: Int -> Int -> Integer
countTuples len k = (1 + fromIntegral k) ^ len
countTuples1 :: Int -> Int -> Integer
countTuples1 len k = fromIntegral k ^ len
binaryTuples :: Int -> [[Bool]]
binaryTuples len = map (map intToBool) (tuples len 1)