MapAt


MapAt allows us to Map a function to specified positions.  The next cell maps
foo to position 3.

ClearAll["Global`*"] ;  MapAt[foo, {a, b, c, d, e, f}, 3]

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

The next cell maps foo to positions {2} and {4}.

MapAt[foo, {a, b, c, d, e, f}, {{2}, {4}}]

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


Created by Mathematica  (May 16, 2004)