I wanted to know the most efficient and less resource consuming way to do the following: first, use the Select
function to filter some values out of some list, e.g.
a={1,2,3,4,5,6};
a2=Select[a,EvenQ];
Now, let's create another list of the same length, b={a,b,c,d,e,f}
. I want to pick exactly the same elements that I picked in a, i.e. b2={b,d,f}
. Is there a built-in function that allows me to do that? If not, what would be the quickest way to do that (in terms of computing time)?
Edit: after some useful responses, I want to clarify something: I still want to do the selection in list a
, i.e. I want to know if there is a way to do the selection in both lists a,b
in one single step. What I've thought of is combining both lists with c=Transpose[{a,b}]
and then applying Select
with the condition on c[[i,1]]
, where i
represents the index of either a
or b
. However, if there is any other solution, I'd like to hear it.