リストによる正方行列処理
http://karetta.jp/article/blog/oneline/010976から。
matrix :: Int -> [[Int]] matrix x = let n = (x ^ 2) in [[(n * x + y) | y <- [1..n]] | x <- [0..n - 1]] transpose :: [[a]] -> [[a]] transpose xss = [[xs !! y | xs <- xss] | y <- [0..(length xss - 1)]] box :: [[a]] -> [[a]] box xss = map concat $ concatMap (transpose . map (split n)) $ split n xss where n = floor $ sqrt $ fromIntegral $ length xss split :: Int -> [a] -> [[a]] split n [] = [] split n xs = take n xs:split n (drop n xs)