[Haskell-cafe] Missing join and split

Benja Fallenstein benja.fallenstein at gmail.com
Fri Dec 28 10:24:38 EST 2007

On Dec 28, 2007 3:55 PM, David Roundy <daveroundy at gmail.com> wrote:
> On Dec 28, 2007 9:51 AM, Benja Fallenstein <benja.fallenstein at gmail.com> wrote:
> > If you use intercalate to join, I would presume that you would want to
> > use an inverse of it to split. I'd write it like this:
> Of course, there is no inverse to intercalate

Right; I misspoke. What I meant was that you would want a split such that

    intercalate a (split a xs) = a

for finite, total (a,xs) (and, since it's achievable, even for
infinite xs). Of course, (split a xs = [xs]) satisfies that, but if we
add the requirement that split is also supposed to do its job :-) then
I think split is fully specified except for whether (split a [] = [])
or (split a [] = [[]]). The latter seems better to me; e.g., it

    split a (x ++ a ++ y) = split a x ++ split a y

> so if you want to use a "logical"
> approach, perhaps you'd want to define split first, and then define
> your join as the inverse of split.

If your join comes out as being intercalate, I suppose it's six of
one, half a dozen of the other :-)

- Benja

More information about the Haskell-Cafe mailing list