MapIndexed
Tilgjengelig
Applies a function to each element and its index.
MapIndexed[f, expr]
MapIndexed[f, expr, levelspec]
MapIndexed[f]
MapIndexed[f, {a, b, c}]
→ {f[a, {1}], f[b, {2}], f[c, {3}]}MapIndexed[f, <|"x" -> 10, "y" -> 20|>]
→ <|x -> f[10, {Key[x]}], y -> f[20, {Key[y]}]|>MapIndexed[f, {{1, 2}, {3, {4, 5}}}, -2]
→ {f[{1, 2}, {1}], f[{3, f[{4, 5}, {2, 2}]}, {2}]}MapIndexed[f, {{1, 2}, {3, {4, 5}}}, {-1}]
→ {{f[1, {1, 1}], f[2, {1, 2}]}, {f[3, {2, 1}], {f[4, {2, 2, 1}], f[5, {2, 2, 2}]}}}MapIndexed[f, {{1, 2}, {3, {4, 5}}}, Infinity] == MapIndexed[f, {{1, 2}, {3, {4, 5}}}, -1]
→ True Alle 6300 funksjoner ·
Bruk dette fra en MCP-klient