import Control.Monad for :: [a] -> (a -> b) -> [b]for = flip map cube :: Integer -> Integer -> Integer -> [[[Integer]]]cube x y z = for [0..x-1] $ \i -> for [0..y-1] $ \j -> for [0..z-1] $ \k -> z*y*i + z*j + k main :: IO ()main = printCube $ cube 2 3 4 where printCube = mapM_ ((const $ putStrLn "") <=< mapM_ print)
Standard input is empty
[0,1,2,3] [4,5,6,7] [8,9,10,11] [12,13,14,15] [16,17,18,19] [20,21,22,23]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!