# Defining the "iteration" before defining a Table

**URL:** <https://community.wolfram.com/t/defining-the-iteration-before-defining-a-table/17457>\
**Category:** Questions\
**Created:** [January 20, 2021, 10:24am UTC](https://community.wolfram.com/t/defining-the-iteration-before-defining-a-table/17457 "2021-01-20T10:24:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![francoishurter](https://avatars.discourse-cdn.com/v4/letter/f/90ced4/32.png) [@francoishurter](https://community.wolfram.com/u/francoishurter)\
**Post date:** [January 20, 2021, 10:24am UTC](https://community.wolfram.com/t/defining-the-iteration-before-defining-a-table/17457/1 "2021-01-20T10:24:29Z")

</div>

Hi,

I have 2 functions f[x] and g[x] defined.

I would like to compare them by displaying some values.  
So I build two tables :

```
tbA = Table[f[x],{x,1,4}]

tbB = Table[g[x],{x,1,4}]

```

Can I define the “iterations” i.e. {x,1,4} before defining the tables, so as I have not to duplicate them?  
Thanks for help.

---

<div class="post-metadata">

**Author:** ![rohitnamjoshi](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@rohitnamjoshi](https://community.wolfram.com/u/rohitnamjoshi)\
**Post date:** [January 20, 2021, 3:14pm UTC](https://community.wolfram.com/t/defining-the-iteration-before-defining-a-table/17457/2 "2021-01-20T15:14:30Z")

</div>

Hi Francois

Since `Table` has the `HoldAll` attribute this does not work

```
xRange = {x, 1, 4};

Table[x, xRange]
(* Non-list iterator xRange at position 2 does not evaluate to a real numeric value *)

```

Have to force evaluation

```
Table[x, Evaluate@xRange]
(* {1, 2, 3, 4} *)

```

To keep the range separate from the iteration symbol

```
range = {1, 4};

Table[x, Evaluate@{x, Splice@range}]
(* {1, 2, 3, 4} *)

```

---

<div class="post-metadata">

**Author:** ![francoishurter](https://avatars.discourse-cdn.com/v4/letter/f/90ced4/32.png) [@francoishurter](https://community.wolfram.com/u/francoishurter)\
**Post date:** [January 20, 2021, 3:28pm UTC](https://community.wolfram.com/t/defining-the-iteration-before-defining-a-table/17457/3 "2021-01-20T15:28:55Z")

</div>

Thank you !

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [January 20, 2021, 3:56pm UTC](https://community.wolfram.com/t/defining-the-iteration-before-defining-a-table/17457/4 "2021-01-20T15:56:48Z")

</div>

If you need to compare the values, you may try this:

```
Table[{f[x], g[x]}, {x, 1, 4}] // TableForm

```

---

<div class="post-metadata">

**Author:** ![mikebesso](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mikebesso/32/22282_2.png) [@mikebesso](https://community.wolfram.com/u/mikebesso)\
**Post date:** [January 23, 2021, 3:25pm UTC](https://community.wolfram.com/t/defining-the-iteration-before-defining-a-table/17457/5 "2021-01-23T15:25:56Z")

</div>

[@Rohit Namjoshi](https://community.wolfram.com/web/rohitnamjoshi) , [@Gianluca Gorni](https://community.wolfram.com/web/gianlucagorni) :

I’ve been struggling with this as well. Now I understand why I was struggling, and I have two new techniques to use.
