I'd like to define a table of functions like so

Table[Function[{x,y},{x + k y,x - k y}] , {k,1,10}]

My intention is to have the first function defined with k=1, the second with k=2, etc. This is not what happens; they are all defined with the variable k.

I think it has to do with evaluation time. When applying these functions, they will use k, however k is defined in application time.

How can I correct this behavior ?


You need a function that creates a function of k.

Table[Function[{x, y}, {x + # y, x - # y}] &[k], {k, 1, 10}]

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