1

Is there a way to make the Function construct accept a list as argument ?

Writing

Function[{x,y},{x+y,x-y}]

does not work, since it accepts two arguments and not a single list.

My aim is to generate a table of functions, say

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

and then to compose them in different ways. Since every such function returns a list, I would like it also to accept a list, to enable composition.

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
Teddy
  • 153
  • 4

1 Answers1

3

The simple way is to write

func = Table[With[{k = k}, {#[[1]] + k #[[2]], #[[1]] - k #[[2]]} &], {k, 10}];

then

Through[func[{a, b}]]

gives

{{a + b, a - b}, {a + 2 b, a - 2 b}, {a + 3 b, a - 3 b}, {a + 4 b, a - 4 b}, 
 {a + 5 b, a - 5 b}, {a + 6 b, a - 6 b}, {a + 7 b, a - 7 b}, {a + 8 b, a - 8 b}, 
 {a + 9 b, a - 9 b}, {a + 10 b, a - 10 b}}
m_goldberg
  • 107,779
  • 16
  • 103
  • 257