# How to define a list of symbols as a list of functions?

I have a list in Mathematica for example

P={1+t,1+t+t^2,1+t+t^3};


My question is, how I can define each element of this list be a function of t? Indeed I want something like this input

P[][.2]


which its output is

1.2


Thanks.

• you can do something like p[] /. t -> .2 while this is not a function, it will give the same out you are looking for. – Nasser Feb 5 '15 at 22:47
• @Nasser Thanks a lot. Put your comment as answer. – Qaher Feb 5 '15 at 22:51

There are few ways to do this. The simplest might be

   p = {1 + t, 1 + t + t^2, 1 + t + t^3};
p[[n]] /. t -> .2


where n is the index. Or you can convert the list to actual functions like this

p = Function[t, #] & /@ p And now you can write p[[n]][.2] as you wanted.

Now for example, you can evaluate all these function for at some value using

  p[[#]][.1] & /@ Range[Length[p]] I am sure there are other ways to do this.

Try this:

p[m_, t_] := Table[Sum[t^i, {i, 0, n}], {n, 1, m}];


Then the list of three elements you gave in your question is obtained as follows:

    p[3, t]

(*   {1 + t, 1 + t + t^2, 1 + t + t^2 + t^3}   *)


and the first term of the list is

p[3, 0.2][]

(*  1.2   *)


Have fun!