haskell - split string logic error -
haskell - split string logic error -
hello function should take string , homecoming list of strings split @ char c. should define helper functions user must initialize args should hidden them.
xs = output list, = start index substr, j = end index substr
example: split "123,456,789" ',' [] 0 0
should yield ["789", "456", "123"]
split s c xs j = if j == length s (substr s j) : xs else if head (drop j s) == c split s c (substr s j : xs) (j + 1) (j + 1) else split s c xs (j + 1) substr s j = take j(drop s) when apply function next args: split "123,456,789" ',' [] 0 0
i'm getting result: ["789", "456,789", "123"]
i mentioned on other post, issue substr function. if alter substr s j = take (j-i) (drop s) should work. , if that's want, great. written more , using takewhile, or using split data.text.
also, type signatures please. (although appreciate defined inputs time.) not create easier help, can solve own problems in process of figuring them out.
haskell split tokenize
Comments
Post a Comment