Binary comprehensions

Luke Gorrie luke@REDACTED
Fri Aug 13 15:44:24 CEST 2004


Jay Nelson <jay@REDACTED> writes:

> Has anyone requested binary comprehensions?

Speaking of comprehensions, does anyone else think that the way
multiple generators in a list comprehension works is weird? I think
this behaviour would be better:

  [{X,Y} || X <- [1,2,3], Y <- [a,b,c]]    => [{1,a},{2,b},{3,c}]

i.e. to walk over the lists in parallel instead of trying all the
combinations. I'm always writing code that walks down two lists in
parallel and very rarely wanting all the combinations.

I'm not suggesting it be changed (of course). I just think it's funny
that list comprehensions turn up in lots of programminig languages and
I hardly ever see someone use more than one generator at a time.
Syntactic sugar should optimize for the most common cases, right?

-Luke




More information about the erlang-questions mailing list