[erlang-questions] List comprehensions challenge ;-)
Wed Jan 12 13:02:00 CET 2011
On 12 jan 2011, at 10.08, Arnaud GARCIA wrote:
> 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]].
> 30> lists:sum([A+B || A <-[1,2,3],B <- [7,8,9,10,11]]).
> Any idea ?
You need to fold it.
Out of topic, this problem have a solution that has better complexity.
"Have run Make so many times I dunno what's installed anymore"
More information about the erlang-questions