# How Can I Use an Element of a Tuple as an Argument for a Pure Function?

(If I should elaborate on the circumstances, tell me.)

I want to do the following: Suppose I have a tuple

 tuple={x,4,something,...}


and I want to define a pure function, e.g.

Function[{tuple[[1]]},x^2]


What I expect is that it uses the first element of tuple as the variable in x^2, that is x. However, what I get is that {tuple[[1]]} is not a list of symbols.

(Evaluate around tuple does not help.)

Can someone explain why this does not work and how it would work?

EDIT: So apparently my remark "Evaluate around tuple does not help." was not quite correct. To fix this, one simply has to do Evaluate@{tuple[[1]]} rather than (what I tried first) {Evaluate@tuple[[1]]}

• Context: I defined a custom Integration that should work with the same syntax as the normal Integrate: cIntegrate[f,{x,x2,x2}], where I need to parse x, the first element of my tuple, as the variable to be integrated. The reason is something about speed of this operation Commented Jan 14 at 9:48
• Use this form instead. (#^2)&[tuple[[1]]] The way you did it does not work since tuple[[1]] is not a formal parameter name Commented Jan 14 at 10:06
• @Nasser But this is backwards from what I'm doing. If I already have my pure Function in the form (#^2)&, I would be done already. The Problem is, that I have an algebraic expression such as "x^2" and I want to convert it to (#^2)& using the built-in Function[]. And the Argument I want it to convert is given by an element of a tuple, i.e. "x" here. Commented Jan 14 at 10:32
• I would write an addendum with the correct answer for other people who may have the same problem. Commented Jan 14 at 12:52
So apparently my remark "Evaluate around tuple does not help." was not quite correct. To fix this, one simply has to do Evaluate@{tuple[[1]]} rather than (what I tried first) {Evaluate@tuple[[1]]}