0
Basically, from the string "222 2333 33"
, I wanted to split into several strings, when you find an empty space or a different number next to you.
For example, in the string above I wanted it to be ["222","2","333","33"]
.
The code I made is below, only in my case I can only divide when it finds the empty space. Missing when the numbers are different.
sliceIt :: String -> [String]
sliceIt xs = words xs
And it would be possible to do this problem with recursion?
You cannot use a ready-made function? split
– rLinhares
Can I, but in this case how would I use it? Because I want it to split whenever it finds empty space or a different number
– Joseph Smith
I did what I could to improve the editing, but please: DO NOT USE IMAGE, enter the code
– Wallace Maxters
I won’t know how to answer because I don’t know anything from Haskell, but a suggestion is you go through the string, when meeting a different guy from the previous one, add a blank (
" "
) and then use the split..– rLinhares