I am new to elixir and had questions regarding iterating over a list using Enum.each(). I want to iterate over a list and append items that satisfy a certain condition to another list.
I provided the code below and commented using pseudocode on what I mean by this.
def test do list = [1,2,3,4,5,6,7,8,9] p1 =  p2 =  p3 =  Enum.each(list, fn(i) -> #if (i) is at index 0 or 2 add (i) to [p1] #if (i) is at index 1 or 3 add (i) to [p2] #else add (i) to [p3] end) end
Is this possible to do using Enum.each() or is there another preferred way of doing such a problem?