List comprehensions challenge ;-)

Arnaud GARCIA <>
Wed Jan 12 10:08:55 CET 2011


Hello,

Just playing with list comprehensions...

I was asking if it possible to do it without lists:sum, by using an
anonymous function and add it directly in the list comprehensions ?

26> [A+B || A <-[1,2,3],B <- [7,8,9,10,11]].
[8,9,10,11,12,9,10,11,12,13,10,11,12,13,14]
30> lists:sum([A+B || A <-[1,2,3],B <- [7,8,9,10,11]]).
165

Any idea ?

Thanks

Arnaud


More information about the erlang-questions mailing list