Re: Why is there no splitBy in the list module?

Jared Updike wrote:
"split" is... unconcatIntersperse.
How about "separate"? ("split" or "splitBy" is better but it is used all over the place in many libs)
And for strings I definitely would use split :: [a] -> [a] -> [[a]] a lot, just like Python's split function. And "words" works great for breaking on multiple spaces, so I would avoid trying to fill that need...
FWIW my home-grown versions of these things are called fields and unfields.

2006/7/12, tpledger@ihug.co.nz
Jared Updike wrote:
"split" is... unconcatIntersperse.
How about "separate"? ("split" or "splitBy" is better but it is used all over the place in many libs)
And for strings I definitely would use split :: [a] -> [a] -> [[a]] a lot, just like Python's split function. And "words" works great for breaking on multiple spaces, so I would avoid trying to fill that need...
FWIW my home-grown versions of these things are called fields and unfields.
Also, my version of the "split but don't drop the delimiter" is breakAll, since it's like a recursive break. words/unwords and lines/unlines have one argument, so a 2 argument fielts/unfields would break that "convention". Maybe: fields = csv `separateWith` "," csv = fields `joinWith` "," -- equivalent to concatIntersperse

On Wed, 12 Jul 2006, Evan Laforge wrote:
Also, my version of the "split but don't drop the delimiter" is breakAll, since it's like a recursive break.
words/unwords and lines/unlines have one argument, so a 2 argument fielts/unfields would break that "convention". Maybe:
fields = csv `separateWith` "," csv = fields `joinWith` "," -- equivalent to concatIntersperse
I may be confused about your point, but I think the way we get split functions down to one parameter is by partial application - commaSplit = splitBy (== ',') fields = commaSplit csv Hence I would much rather have the split condition be the first parameter -- the infix notation looks good, but it will need a "flip" to get the parameters in the right order. Donn Cave, donn@drizzle.com

fields = csv `separateWith` "," csv = fields `joinWith` "," -- equivalent to concatIntersperse
Hence I would much rather have the split condition be the first parameter -- the infix notation looks good, but it will need a "flip" to get the parameters in the right order.
This also goes along with join in python, i.e. "\n".join(xs) ==> "\n" `join` xs in Haskell (where join sep = concat . intersperse sep ) Jared.

Quoth "Jared Updike"
participants (4)
-
Donn Cave
-
Evan Laforge
-
Jared Updike
-
tpledger@ihug.co.nz