What is the best way to split a string by a delimiter functionally?

后端 未结 9 1776
死守一世寂寞
死守一世寂寞 2020-12-29 22:11

I tried to write the program in Haskell that will take a string of integer numbers delimitated by comma, convert it to list of integer numbers and increment each number by 1

9条回答
  •  时光说笑
    2020-12-29 22:44

    splitBy del str = helper del str []   
        where 
            helper _ [] acc = let acc0 = reverse acc in [acc0] 
            helper del (x:xs) acc   
                | x==del    = let acc0 = reverse acc in acc0 : helper del xs []  
                | otherwise = let acc0 = x : acc     in helper del xs acc0 
    

提交回复
热议问题