我正在尝试编写一个Haskell代码,它接受一个列表并返回列表。当我这样做,如下面的代码,我得到“的功能重组非详尽模式”在Haskell中将相同长度的子列表打破列表
reGroup :: [[Int]] -> [Int] -> [[Int]]
reGroup [[]] [] = [[]]
reGroup [[]] xs = reGroup [(take 3 xs)] (drop 3 xs)
reGroup [[a]] [] = [[a]]
reGroup [[a]] xs = reGroup [[a], (take 3 xs)] (drop 3 xs)
-- calling the reGroup function from another function as follow
reGroup [[]] [1,2,3,4,5,6,7,8,9]
我要的是[1,2,3,4,5,6,7,8,9]
- >[[1,2,3], [4,5,6], [7,8,9]]
。我做错了什么或有人能告诉我一个简单的方法?
+1尼斯使用模式匹配 – 2013-03-07 22:23:11
的(我认为你有1太多的括号层在'[其他]'。) – huon 2013-03-07 22:28:19
@dbaupp现在固定。 – 2013-03-07 23:13:42