43

15

I need a table with the elements made of pure functions and list elements. This is a simplified example:

I need a list as:

```
{a[[1]]*Sin[#]&,a[[2]]*Sin[#]&,a[[3]]*Sin[#]&}
```

and, my failed try is : `Table[a[[i]]*Sin[#]&,{i,3}]`

Why is the failure and how can I improve it?

Has anyone mentioned Evaluate?"Table[Evaluate[a[[i]]*Sin[#]]&,{i,3}]" – None – 2014-02-03T15:50:40.857

2What's

`a`

supposed to be? Do you need something like the result of`Function[c, c Sin[#] &] /@ Range[3]`

or`Table[With[{cs = c}, cs Sin[#] &], {c, Range[3]}]`

? – J. M.'s ennui – 2012-07-01T17:13:41.803This may be relevant. – Leonid Shifrin – 2012-07-01T17:23:06.443

@R.M, that puts the constant outside the

`Function[]`

as opposed to the inside, no? – J. M.'s ennui – 2012-07-01T17:23:07.5403@WReach, nice to see you around. Undelete your post!! – Rojo – 2012-07-01T17:27:47.047

Also, I illustrate various techniques of generating lists of pure functions with injected elements (very close to what you ask for), in this answer.

– Leonid Shifrin – 2012-07-01T17:27:48.3101@LeonidShifrin, you'll make him cry while trying to follow that code! – Rojo – 2012-07-01T17:29:24.127

@Rojo But the part on pure functions is in the middle of the post, and independent on anything else - have a look. – Leonid Shifrin – 2012-07-01T17:30:15.297

@LeonidShifrin I see. Then you'll make him happy :) – Rojo – 2012-07-01T17:31:38.713

Rojo, JM: you're right. Heh, I need breakfast – rm -rf – 2012-07-01T17:31:51.083

Wow, Rojo and WReach posted at the exact same time, down to the second! – rm -rf – 2012-07-01T17:32:51.130

@R.M. Apparently, one second granuarity is not enough (too coarse). – Leonid Shifrin – 2012-07-01T17:34:21.597

8My favorites for this problem would still be either

`Range[3] /. i_Integer :> (a[[i]] Sin[#] &)`

or`Array[Function[x, a[[x]] Sin[#] &], {3}]`

. – Leonid Shifrin – 2012-07-01T17:38:34.043