[erlang-questions] Question on building a variable with multiple math operations
Illo de' Illis
illo@REDACTED
Fri Jul 10 17:34:56 CEST 2009
On Jul 10, 2009, at 5:29 PM, Illo de' Illis wrote:
> On Jul 10, 2009, at 5:17 PM, Greg Perry wrote:
>
>> [...]
>> I have been experimenting with lists:fold1 but it seems that is
>> expecting a simple list without the use of tuples.
>>
>> Any ideas on this one?
>
> Isn't it as simple as doing:
>
> lists:foldl(fun erlang:'+'/2, 0, [X*Y || {X,Y} <- N1]).
Or
lists:foldl(fun ({X,Y},A) -> (X*Y)+A end, 0, N1).
Ciao,
Illo.
More information about the erlang-questions
mailing list