inaka/erlang_guidelines — pull request #8 by elbrujohalcon (2014-09-15 21:06:50+00:00)
Title: Suggestion: use lists:foreach or LC instead of lists:map

##### rule
> Replace ``lists:map`` with either ``lists:foreach`` or list comprehensions

```erlang
%% bad
lists:map(
fun(#rec{field=Value}) ->
process(Value)
end, List).

%% good (in case you want the results)
[process(Value) || #rec{field=Value} <- List].

%% good (in case you don't want to use the results)
lists:foreach(
fun(#rec{field=Value}) ->
process(Value)
end, List).
```
##### reasoning
If you're not using the results, you should not generate them (thus the need for ``foreach`` that always return ``ok``). On the other hand, if you **do** need them, list comprehensions are clearer, shorter, etc. **unless** you do stuff like ``lists:map(fun process_rec/1, List)``