我想添加1個項目到只有一個項目和添加項目(使用toInt轉換爲整數後)列表中y如果項目數量大於1和最後項目是相同的如何在列表中使用像if then else語句那樣的過濾器?
怎麼辦?
import Data.List.Split
z = splitOn "+" "x^2+2*x^3+x^2"
y = map (splitOn "*") z
x = map head y
toInt :: [String] -> [Int]
toInt = map read
u = filter ((map length y)>1) y
Couldn't match expected type `a0 -> Bool' with actual type `Bool'
In the first argument of `filter', namely `((map length y) > 1)'
In the expression: filter ((map length y) > 1) y
In an equation for `u': u = filter ((map length y) > 1) y
失敗,已加載模塊:無。
我希望選擇列表哪個長度大於1 – Jo0o0 2011-04-17 14:36:21