4
$\begingroup$

This question already has an answer here:

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

$\endgroup$

marked as duplicate by WReach, m_goldberg, b3m2a1, LCarvalho, JungHwan Min Aug 5 '18 at 1:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4
$\begingroup$

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.

$\endgroup$

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