[erlang-questions] List comprehensions challenge ;-)
Wed Jan 12 10:15:19 CET 2011
List comprehensions are a combination of lists:map/2 and
lists:filter/2. But lists:sum/1 is a lists:foldl/3 type, this cannot
be handled with list comprehensions.
On Wed, Jan 12, 2011 at 12:08 PM, 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 ?
More information about the erlang-questions