I need to create my own words functions. It takes string and puts into list where ever there is space. For example string "i need help" would result in ["i","need","help"]. The definitions must be exactly
anything :: String -> [String]
I currently came up with stupid solution which look like this ( also it doesn't work)
test :: String -> [String]
test d = beforep d : (test (afterp d)) : []
beforep :: String -> String
beforep d = takeWhile (/=' ') d
afterp :: String -> String
afterp d = if (dropWhile (/=' ') d)==[] then []
else tail(dropWhile (/=' ') d)
test -> uses tail recursion
beforep -> get everything till first space
afterp -> gets everything after space
Any ideas ? If you have any other solutions to this problem it would help. Thank you