Tag Info

Hot answers tagged

4

I think this is probably what you were looking for: Map[Position[index, #][[1, 1]] &, initial, {2}] {{4, 2}, {1, 3}, {1, 4}} Please see: What does "levelspec" mean in the documentation? Levels: how do they work? However you should avoid mapping Position whenever possible as it is highly inefficient. See: Why is there no ...


2

Based on the Answer by @MrWizard, initial /. First /@ PositionIndex[index] also works.


1

First, Position can work directly on more than one value but through Alternatives. Flatten[Position[index, Alternatives @@ #]] & /@ initial (*{{2, 4}, {1, 3}, {1, 4}}*) but as you can see that Position starts with the first position found {2,4} which is not the way you want. you can use Map to map the Position function on each elements in the list ...



Only top voted, non community-wiki answers of a minimum length are eligible