Adding split/split' to Data.List,
and redefining words/lines with it; also, adding replace/replaceBy
lemming at henning-thielemann.de
Fri Jul 11 01:23:57 EDT 2008
On Thu, 10 Jul 2008, David Roundy wrote:
> On Fri, Jul 11, 2008 at 12:11:15AM +0100, Neil Mitchell wrote:
>>> What do people think of adding these?
>> split is sorely lacking, and definately needs to be included. However,
>> my version is different to yours:
> I would suggest that when everyone defines a different version of a
> function, then it isn't actually such a good function to put into the
> standard libraries.
I think the problem is, that there is no commonly agreed data structure
for a list of alternating elements, like this one:
With this intermediate form, you could have a generic 'split' function
split :: (a -> Bool) -> [a] -> AlternatingList a [a]
from which you can derive several flavours easily, by extracting only the
[a] elements, or by turning 'a' into [a] and flatten the alternating list
then, or by fusing pairs of 'a' and [a].
More information about the Libraries