我正在尝试在Haskell中实现Ravi Sethi的Little Quilt语言.可以在这里看到Sethi的小被子的概述:http://poj.org/problem?id = 3201
这是我到目前为止的功能:
import Data.List.Split
rotate :: Int -> [a] -> [a]
rotate n xs = iterate rot xs !! n
where
rot xs = last xs : init xs
turn :: [a] -> [a]
turn x = rotate 2 x
grid :: Int -> [String] -> String
grid n = unlines . map concat . chunksOf n
printAtom :: [String] -> IO()
printAtom x = putStrLn $ grid 2 x
Run Code Online (Sandbox Code Playgroud)
我实现rotate了在我的 …