从文件中读取这些行并制作一个这样的列表
2010‐04‐16,130.68,132.17,130.25,130.63,9546200,130.63
2010‐04‐15,130.53,131.14,130.19,130.89,6425300,130.89
List [ "2010‐04‐16","130.68,132.17","130.25","130.63","9546200","130.63"]
我怎么能用take谓词做这个?或任何其他谓词
答案 0 :(得分:0)
我可以使用Data.List
API执行类似的操作:
import Data.List
split :: Eq a => a -> [a] -> [[a]]
split delim = map (dropWhile (== delim)) . groupBy (\_ c -> c /= delim)
带有一个输入字符串的输出将是:
Prelude Data.List> split ',' "20100416,130.68,132.17,130.25,130.63,9546200,130.63"
["20100416","130.68","132.17","130.25","130.63","9546200","130.63"]
... HTH