I am new to haskell, I tried to write a line splitting function
delim = '|' splitStr::[Char]->[[Char]]->[[Char]] splitStr list y | sL > 0 && sL < length(list) = splitStr (drop (sL+1) list) [subList]++y | otherwise = [subList]++y where subList = takeWhile (\x -> x /= delim) list sL = length(subList) split s = splitStr s []
However, the above code always returns the string in reverse order
Main> split "foo|bar|java|python" ["python","java","bar","foo"]
changing from y++[subList] to [subList]++y still gives the same result. I know there may be better ways to do this, but I want to know why this is happening.
haskell
Rnet
source share