This is a candidate for a duplicate (probably from the documentation) but I've ironically failed to find the direct analog so far.
I have an arbitrary nested list, say:
anl = {first , second, {x, y, z}, {a, {b, c}}}
I need some MMA way to apply f to positions poss if I do not know them:
poss = {{1}, {2}, {3, 1}, {3, 2}, {3, 3}, {4, 1}, {4, 2, 1}, {4, 2, 2}}
So I need 1) an analog to:
MapAt[f, anl, poss]
{f[first], f[second], {f[x], f[y], f[z]}, {f[a], {f[b], f[c]}}}
2) a way to get poss.
Stuck a bit. Thank you for any constructive help in advance.
anl /. a_Symbol :> f[a] /. f[List] :> Listacceptable? – march Dec 20 '15 at 20:57l = Map[f, anl, {-1}]; Most /@ Position[l, f]? – Kuba Dec 20 '15 at 21:06Position[anl, _, {-1}, Heads -> False]– garej Dec 21 '15 at 05:29