Jump to content

Haskell - Alternative to a function (HELP!)

- - - - -

  • Please log in to reply
1 reply to this topic

#1
hank

hank

    Newbie

  • Members
  • Pip
  • 1 posts
Hey guys! I really need an help here. I have a function here, this:

divide :: String -> [String]

divide [] = [""]

divide (c:cs) | c == '\"' = a:(divide (drop 2 b))

              | c == ',' = "":raw

              | otherwise = (c:head raw):tail raw

        where raw = divide cs

              (a,b) = span (/='\"') cs

I need an alternative to this function, that do the same, but in a simple way too. Please, i really need a help, this is my only hope x) .
Cheers!! :D

#2
ambidextrous

ambidextrous

    Newbie

  • Members
  • Pip
  • 4 posts
If you just want to split a string into an array of strings based on commas, maybe you can experiment with using elemIndex and splitAt from Data.List?
Codito ergo sum :loading:




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users