MapAt[f, {{a, b, {c, d}}, {d, {e, g, {c, d}}}}, 1]

How to operate to get such a result:

{{f[a], f[b], {f[c], f[d]}}, {f[d], {f[e], f[g], {f[c], f[d]}}}}

2 Answers 2


One can also temporarily apply a Listable function with

Function[x, f[x], Listable][list]

Listability works differently than mapping to level {-1} when the elements of the list have parts:

Function[x, f[x], Listable][{b, {e, g, {c, a + Exp[d]}}}]
(*  {f[b], {f[e], f[g], {f[c], f[a + E^d]}}}  *)

Map[f, {b, {e, g, {c, a + Exp[d]}}}, {-1}]
(*  {f[b], {f[e], f[g], {f[c], f[a] + f[E]^f[d]}}}  *)

you can also give the attribute Listable to your function

SetAttributes[f, Listable]

and then simply write

f@{{a, b, {c, d}}, {d, {e, g, {c, d}}}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.