我是Haskell的新手,我正在尝试从我的书中运行以下示例代码:
整个档案:
-- my name
splitAt1 :: [a] -> ([a], [a])
splitAt1 xs = (take 2 xs, drop 2 xs)
Run Code Online (Sandbox Code Playgroud)
我正在通过运行线路进行测试:
splitAt1 [1 2 3 4]
Run Code Online (Sandbox Code Playgroud)
想法是输入数组在索引2处被拆分为两个数组.但是,我收到以下错误:
Non type-variable argument
in the constraint: Num (a -> a -> a -> a)
(Use FlexibleContexts to permit this)
When checking that ‘it’ has the inferred type
it :: forall a a1 a2 a3.
(Num a1, Num a2, Num a3, Num (a1 -> a2 -> a3 -> a)) =>
([a], [a])
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我解码错误信息,也许代码有什么问题?
| 归档时间: |
|
| 查看次数: |
6823 次 |
| 最近记录: |