How can I prevent Table[] from evaluating its arguments each time?

  • Context: Mathematica 
  • Thread starter Thread starter matiasmorant
  • Start date Start date
  • Tags Tags
    Mathematica Table
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 4K views
matiasmorant
Messages
38
Reaction score
0
I want to make a Table[] but aI don't want this function to evaluate its argument each time. for example, I want to make the table {12,22,32,42,...}, instead of {1,4,9,16,...}


how?
 
Physics news on Phys.org
Two (out of many) possible approaches

In[1]:= Table[With[{nn=n},Defer[nn^2]],{n,1,10}]
Out[1]= {1^2,2^2,3^2,4^2,5^2,6^2,7^2,8^2,9^2,10^2}
In[2]:= Table[Superscript[n,2],{n,1,10}]
Out[2]= {1^2,2^2,3^2,4^2,5^2,6^2,7^2,8^2,9^2,10^2}

The advantage of the first one, is that if copied and pasted, it will evaluate as normal.
 
Thanks a lot, I could do what I wanted