【发布时间】:2019-03-28 14:52:30
【问题描述】:
如何仅通过前奏的递归和函数将Haskell中的列表(例如“222 33244”)拆分为[“222”,“33”,“2”,“444”]?
我目前的尝试是:
list xs
|length xs == 0 = ""
|otherwise = listSplit xs
listSplit (x:xs)
|x == head xs = x : ListSplitNext x xs
|otherwise = x:[]
listSplitNext a (x:xs)
|a == x = a : listSplitNext x xs
|otherwise = listSplit xs
【问题讨论】:
-
您的尝试有什么问题?
-
我还没试过我想知道如何编码问题
-
没有尝试的家庭作业问题在 StackOverflow 上是题外话:softwareengineering.meta.stackexchange.com/questions/6166/…
-
好吧,您可以分享不起作用的尝试,以便我们帮助修复它。
-
请edit提问。
标签: string list haskell recursion