Parallel list comprehensions

Tomasz Zielonka tomasz.zielonka at
Sat Feb 4 15:18:47 EST 2006

On Sat, Feb 04, 2006 at 11:58:15AM -0800, John Meacham wrote:
> On Sat, Feb 04, 2006 at 03:11:10PM +0100, John Hughes wrote:
> > I noticed ticket #55--add parallel list comprehensions--which according to
> > the ticket, will probably be adopted. I would argue against.
> I disagree. :) I use them all the time and find them very useful.
> however, I do agree with some of your criticisms and would be interested
> if we can think of some sort of generalization of them.

Hmmm... you can use zip, can't you? If you want to zip arbitrary number
of lists, there is a trick that can help:

    zApp = zipWith ($)


    zip3 [1..4] [2..] [3..]

is equivalent to:

    repeat (,,) `zApp` [1..4] `zApp` [2..] `zApp` [3..]

where the latter is easily extensible.

You could also only use zip, if you don't mind working on nested pairs:

    zip (zip [1..4] [2..]) [3..]

I don't use parallel list comprehensions. I am also zipping trees,
and PLCs don't help me here.

Best regards

I am searching for programmers who are good at least in
(Haskell || ML) && (Linux || FreeBSD || math)
for work in Warsaw, Poland

More information about the Haskell-prime mailing list