[erlang-questions] Erlang again!

David Mercer <>
Fri Jul 23 16:21:30 CEST 2010


Do any of y'all ever find yourself writing something like this when you want
to compute an intermediate value only once (in this case, the result of f(X)
is used twice but we only want to compute it once):

    [ {g(Y), h(Y)} || X <- L, Y <- [f(X)] ]

And is there a better way of writing that?  I don't really like having to
put the result f(X) into a single-element list just so it can be pulled out
again.

Cheers,

David



More information about the erlang-questions mailing list