[erlang-questions] Can I do the same with a fold easily

Roelof Wobben <>
Sun Oct 18 21:27:13 CEST 2015


Hello,

I have this two functions :

filter(List, Filter) ->
     lists:filter(Filter, List).

split2(List) ->
     { filter(List, fun(X) -> math_functions:odd(X) end), filter(List, 
fun(X) -> math_functions:even(X) end) }.

which produces both {[1,3],[2,4]}

Could I this also do with a fold or is this the best solution.

Roelof


[

1,3],[2,4]}





More information about the erlang-questions mailing list