I am in trouble with Position, Although my example works as expected it throws a warning.
Position[{{a,b},{a,c},{a,b}}, _?(#[[2]]==b&), {1}]
During evaluation of In[23]:= Part::partd: Part specification List[[2]] is longer than depth of object. >>
(*Out[23]= {{1},{3}}*)
Whats wrong here (MMA 7) ?
Ok, have just realized that adding Heads->False helps
Position[{{a,b},{a,c},{a,b}}, _?(#[[2]]==b&), {1}, Heads->False]
But why is this necessary I allready have specifyed a levelspec of {1} so the Head should be ommited anyway.
Regards Robert
Heads->True,Positionincludes heads of expressions, and their parts. BTW, the answer given by @YvesKlett will not produce such warning. – hengxin Dec 02 '14 at 07:31Position[{{a, b}, {a, c}, {a, b}}, {_, b}]or keeping the levelspec similarPosition[{{a, b}, {a, c}, {a, b}}, {_, b},{1}]. – Yves Klett Dec 02 '14 at 07:38