Skip to main content
1 of 2
geordie
  • 3.7k
  • 1
  • 27
  • 34

Calling blank arguments using enclosing functions

Is there a way to call a function and have that function use an argument defined in an enclosing function?

e.g.,

set = Table@Range@50;

posE[set_] := Select[set, EvenQ]

tform1[mult_,set_] := (#*mult) & /@ set[[posE]];

t1set = tform1[10, set]

which leads to the following message/error,

Part::pspec: Part specification posEa is neither an integer nor a list of integers. >>

I would like posE to get its argument set_ from the second argument in tform1 (also named set_).

Is this possible? is there a better way to do this?

(Note that I do not want to combine the two functions into a single function).

geordie
  • 3.7k
  • 1
  • 27
  • 34