O(m+n) Break a
Text into pieces separated by the first
Text argument (which cannot be empty), consuming the delimiter.
An empty delimiter is invalid, and will cause an error to be raised.
Examples:
>>> splitOn "\r\n" "a\r\nb\r\nd\r\ne"
["a","b","d","e"]
>>> splitOn "aaa" "aaaXaaaXaaaXaaa"
["","X","X","X",""]
>>> splitOn "x" "x"
["",""]
and
intercalate s . splitOn s == id
splitOn (singleton c) == split (==c)
(Note: the string
s to split on above cannot be empty.)
In (unlikely) bad cases, this function's time complexity degrades
towards
O(n*m).