完整的小白在這裏Haskell中,我試圖讓這個下面這段代碼的工作:哈斯克爾類型誤區分配變量
它的意圖是要接受列表的第一EXP元素,將它們連接起來,然後調用同樣的功能。
order (i) (l1)(l2) =
do exp <- (2^i)
l <- (take exp l1) ++ (take exp l2) ++ (order (i+1) (drop exp l1) (drop exp l2));
return l
我敢肯定,這遠不是慣用的哈斯克爾,但你必須從一些地方開始。
我得到的錯誤是在
exp <- (2^i)
說
No instance for (Num [Int])
arising from a use of `^'
Possible fix: add an instance declaration for (Num [Int])
這我真的不能確定這究竟意味着。是不是2和我的整數,然後應用指數函數將導致一個整數?
謝謝!