假设我的[String]为["one", "one", "two", "three", "three", "three"]
我如何将此[String]拆分为
的[[String]] [["one", "one"], ["two"], ["three", "three", "three"]]
感谢您的时间
答案 0 :(得分:3)
如果要按照示例输入中的相等性对连续值进行分组,则执行
Prelude> Data.List.group ["one", "one", "two", "three", "three", "three"]
[["one","one"],["two"],["three","three","three"]]
否则,您可能希望对列表进行排序以获得彼此相邻的相等值。