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
Click For Summary
SUMMARY

This discussion focuses on preventing the evaluation of arguments in the Table[] function in Mathematica. Two effective methods are presented: using Defer within a With statement and employing Superscript for exponentiation. Both approaches yield the same output of {1^2, 2^2, 3^2, 4^2, 5^2, 6^2, 7^2, 8^2, 9^2, 10^2}, with the first method allowing for easy copying and pasting without immediate evaluation. These techniques are essential for users looking to manipulate expressions without triggering evaluation in Mathematica.

PREREQUISITES
  • Familiarity with Mathematica syntax and functions
  • Understanding of the Table[] function in Mathematica
  • Knowledge of the Defer function in Mathematica
  • Basic concepts of exponentiation in programming
NEXT STEPS
  • Explore advanced usage of the Defer function in Mathematica
  • Learn about other Mathematica functions that prevent evaluation
  • Investigate the implications of expression evaluation in Mathematica
  • Study the differences between symbolic and numeric computation in Mathematica
USEFUL FOR

Mathematica users, educators, and students who require control over expression evaluation in their computational tasks.

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
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K