4

If I want to use slots corresponding to different function, how can I dod that. For example:

 Scan[MapIndexed[(#1+#2)*#3&,{"a","b","c"}],Range[5]]

where I want #3 corresponds to elements in Range[5], but obviously it gives me errors. How can I pass #3 to the next function

Liuba Orlova
  • 101
  • 5

1 Answers1

4

You can use the alternative form of anonymous functions with named parameters:

Scan[Function[{x}, MapIndexed[Print[(#1 + #2) x] &, {"a", "b", "c"}]], Range[5]]

The old question of mine, Using several anonymous functions mixed together, comes to mind. It also deals with this issue, although in a different context.

C. E.
  • 70,533
  • 6
  • 140
  • 264