Why is there no splitBy in the list module?
maeder at tzi.de
Tue Jul 11 06:59:16 EDT 2006
John Meacham schrieb:
> just a note: I find splitBy a much nicer routine to provide.
I would support this, if it helped to find a consensus. It's more
difficult to decide if empty lists as elements of the result list (at
the beginning, at the end or in the middle) should be returned. I would
say yes, because removing is quite easy afterwards. The problem
typically occurs with a final newline, that may produce an empty last
line (that again may be closed by a further final newline by mistake)
>> splitBy :: (a -> Bool) -- ^ whether element is a seperator
>> -> [a] -- ^ list to split
>> -> [[a]]
P.S. inspecting more than one element looks like an over-generalization
to me and should be left to parsers or regexp libs.
More information about the Libraries