排序元組的排列在Haskell我寫了代碼進行排序元組列表的指數我嘗試使用地圖與bubblesort()
避免使用環通過索引
bubblesort::(Ord t) => [t]->[t]
bubblesort[x,y,z,xs]=
if x<y then x : map bubblesort [y,z,xs]
else y : map bubblesort [x,z,xs]
,但它給我一個錯誤即:
ERROR line 20 - Type error in list *** Expression : [y,xs] *** Term : xs *** Type : [a] *** Does not match : a *** Because : unification would give infinite type
*注請給我指令只
- 編譯器是在線編譯器
什麼是你想要做什麼呢?只需排序一個列表,或排序一個元組? – NominSim 2012-07-16 17:44:09