parallel LC

Ulf Wiger (AL/EAB) ulf.wiger@REDACTED
Tue Nov 30 15:58:17 CET 2004

For those of you who like to extend the Erlang language, there's a really nifty feature in the language Cryptol ( Cryptol is THE programming language if you want to implement crypto algorithms.

The nifty feature I had in mind is called 'parallel list comprehension'.

  [| (x, y)
   || x <- xs
   || y <- ys|]

if xs = [1 2 3 4] and ys [a b c d], we'd get 

[(1 a) (2 b) (3 c) (4 d)]

which happens to work just like (the undocumented) lists:zip([1,2,3,4], [a,b,c,d]) in Erlang.

The resulting list will be the same length as the shortest list in the parallel comprehension (which differs slightly from lists:zipwith/3 and lists:zipwith3/4)

Implementing parallel LC in Erlang would be a breeze... it's just a matter of hacking some transform code in the compiler. Unfortunately, if I read the source correctly, the transform for list comprehensions is done in Core Erlang, and I'm afraid I'm not up to speed on that.

So, anyone up for a weekend hack?  (-:


More information about the erlang-questions mailing list