module Solutions.P48 (tablen) where
tablen :: Int -> ([Bool] -> Bool) -> [[Bool]]
tablen :: Int -> ([Bool] -> Bool) -> [[Bool]]
tablen Int
n [Bool] -> Bool
f = ([Bool] -> [Bool]) -> [[Bool]] -> [[Bool]]
forall a b. (a -> b) -> [a] -> [b]
map (\[Bool]
xs -> [Bool]
xs [Bool] -> [Bool] -> [Bool]
forall a. [a] -> [a] -> [a]
++ [[Bool] -> Bool
f [Bool]
xs]) ([[Bool]] -> [[Bool]]) -> [[Bool]] -> [[Bool]]
forall a b. (a -> b) -> a -> b
$ Int -> [[Bool]]
enumerate Int
n
enumerate :: Int -> [[Bool]]
enumerate :: Int -> [[Bool]]
enumerate Int
0 = [[]]
enumerate Int
n = [Bool
x Bool -> [Bool] -> [Bool]
forall a. a -> [a] -> [a]
: [Bool]
xs | Bool
x <- [Bool
False, Bool
True], [Bool]
xs <- Int -> [[Bool]]
enumerate (Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1)]