[erlang-questions] Can I do the same with a fold easily
Éric Pailleau
eric.pailleau@REDACTED
Sun Oct 18 23:10:23 CEST 2015
Hi,
A number cannot be both even and odd, so simply take odd numbers in a variable O from list L , even numbers will be L -- O.
Le 18 oct. 2015 21:27, Roelof Wobben <r.wobben@REDACTED> a écrit :
>
> 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]}
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
More information about the erlang-questions
mailing list