【发布时间】:2020-04-27 14:07:54
【问题描述】:
我是 haskell 的新手,我想创建一个函数来获取列表列表的第 x 个元素并返回它。
示例:[[14, 15, 84], [84, 79, 78], [45, 78, 98], [45, 48, 98]] 我只想要第 2 个所以我的函数需要返回 : [[14, 15, 84], [84, 79, 78]]
push :: [a] -> [[a]] -> [[a]]
push = (:)
generateKluster :: Int -> Int -> [[Int]] -> [[Int]] -> [[Int]]
generateKluster nb_return count (a:as) b
| nb_return == count = b
| nb_return < count = (generateKluster x (y + 1) as (push a b))
我收到了这个错误信息
*Main> 3 0 [[12, 45, 52], [14, 15, 65], [15, 46, 48], [45, 78, 98], [45, 65, 45]] [[]]
<interactive>:1:1: error:
• Non type-variable argument
in the constraint: Num (t1 -> [[a1]] -> [[a2]] -> t2)
(Use FlexibleContexts to permit this)
• When checking the inferred type
it :: forall t1 a1 a2 t2.
(Num (t1 -> [[a1]] -> [[a2]] -> t2), Num a1, Num t1) =>
t2
【问题讨论】:
标签: list haskell compiler-errors