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

Close to what you want but I wait for clarification: expr= { -1, {-1}, {-1, -1}, {-1, -1, {-1}}, {-1, {-1}}, {-1, -1, {-1}, {-1, -1}, {-1, -1}, {-1, -1}}, {-1, {-1}, {-1, -1}}, {-1, {-1}, {-1, -1}, {-1}} }; Replace[ -expr, {x__} :> 1 - +x, -1 ] {1, 0, -1, -1, 0, 2, 1, 1}


2

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


2

If y is a packed array then Dot should be quite fast: y = RandomReal[{0, 1}, {10^5, 2}]; x = 12.3; result = y.{{1, 0}, {0, 1/x}}; This takes about a millisecond on my not-very-fast PC.


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 ...


1

Your question is missing information about city coordinates and mapping of the x,y coordinates in your calculations to world coordinates, so that part of the question you have to work out yourself, but that shouldn't be to difficult. Combining your plot with city data is not too difficult either. First, to get a plot of the region you want, like Nancy, ...



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