# How to use indices during Map?

I want to map a function on each element at the "deepest" level of a list.

The list can have an arbitrary number of dimensions.

The function needs the indices of the element to which it is being mapped.

How can I determine the indices of an element during mapping ?

• for example?${}$ Aug 16 '19 at 13:28
• does Map[MapIndexed[foo, #] &, list, {-2}] or MapIndexed[foo, list, {Depth[list] - 1}] give what you need?
– kglr
Aug 16 '19 at 13:34
• Yes, MapIndexed provides exactly what I need. Thanks AFT. Aug 16 '19 at 13:44

list = {a, {{b, c}, {d, e}}};