想知道如果我能得到一些幫助寫這個功能。我試圖創建一個函數來反轉列表中的每個「對」。Haskell反轉對
module Invert where
invert :: [(a,b)] -> [(b,a)]
invert [(a,b)] = [(b,a)]
當我進入invert [(3,1) (4,1) (5,1)]
...它應該給我[(1,3) (1,4) (1,5)
...但它給了我......
*Invert> [(3,1) (4,1) (5,1)]
<interactive>:2:2:
The function `(3, 1)' is applied to two arguments,
but its type `(t0, t1)' has none
In the expression: (3, 1) (4, 1) (5, 1)
In the expression: [(3, 1) (4, 1) (5, 1)]
In an equation for `it': it = [(3, 1) (4, 1) (5, 1)]
忘記逗號笑......但它仍然給我「在功能反轉非詳盡模式」 – 2013-02-11 17:18:16