所以我有這個功能如何將head(xs)作爲一個參數傳遞給另一個函數?
intCMP :: Int -> Int -> Ordering
intCMP a b | a == b =EQ
| a < b = LT
| otherwise = GT
和定義
xs = [1,2,3]
我試圖找到有關該列表的信息,但我有troouble傳球元素融入intCMP
這此列表是我想要做的
intCMP head(xs) 1
但是,這給我和錯誤說它有太多的爭論。
<interactive>:2:9: error:
• Couldn't match expected type ‘Int’ with actual type ‘Integer’
• In the first argument of ‘intCMP’, namely ‘(head xs)’
In the expression: intCMP (head xs) 1
In an equation for ‘it’: it = intCMP (head xs) 1
能否請您分享精確的輸出運行你的程序,以及源代碼的統一視圖? –
這就是我所有的源代碼,只是函數和定義的列表。但我會告訴你錯誤。 – christian
'intCMP(head xs)1'和'intCMP head(xs)1'之間存在(或者應該有所不同)。 – chepner