What does || mean in Erlang? -
i found there ||
in list manipulation. ||
mean? there examples ||
?
lists:sum([a*b || {a, b} <- foo]).
it used in list comprehensions. list comprehensions shorter way create lists without having use funs, maps or filters.
from programming erlang:
if have list l:
l = [1,2,3,4,5].
and want double every element, can do:
lists:map(fun(x) -> 2*x end, l).
but list comprehensions can do:
[2*x || x <- l].
Comments
Post a Comment