How to display underlaying symbolic function but not calculating the result

Hi All,

given the data list:-

data = {24, 5, -9, 105, 15, 111};

Table[data[[i]], {i, 1, 6}]  (* which shows the values in the data list *)

Out[]= {24, 5, -9, 105, 15, 111}

BUT I want Table[data[[i]],{i,1,6}]
( How can I code the output to show the under laying symbolic as shown below )
{ data[[1]], data[[2]], data[[3]], data[[4]], data[[5]], data[[6]] }

Many thanks for any help your can offer.
Lea…

Hi,

Table[With[{i = i}, Defer[data[[i]]]], {i, 1, 6}]

returns what you need where the resultant list

{data[[1]], data[[2]], data[[3]], data[[4]], data[[5]], data[[6]]}

evaluates to

{24, 5, -9, 105, 15, 111}

A great primer on programmatically creating expressions

Some other cases of using With[{i=i},...]

https : //
reference.wolfram.com/language/howto/
EvaluateExpressionsInsideDynamicOrManipulate.html

https://mathematica.stackexchange.com/questions/141596/differentiate-values-inside-table-using-dynamic

Excellent Ben.
Exactly what I wanted.
Many thanks for your help,
Lea…

Hi Ben & All,

Further to your excellent recommendation of the use of the Defer[ ] function.
I am trying to incorporate “Defer” into the following, but cannot seem to get the desired result.
Please could you show the coding using Defer to get :-

    FoldList[Plus, 0, Table[data[[i]], {i, 10}]] // TableForm
   
0,

data[[1]],

data[[1]]+data[[2]],

data[[1]]+data[[2]]+data[[3]],

data[[1]]+data[[2]]+data[[3]]+data[[4]],

data[[1]]+data[[2]]+data[[3]]+data[[4]]+data[[5]],

data[[1]]+data[[2]]+data[[3]]+data[[4]]+data[[5]]+data[[6]],

data[[1]]+data[[2]]+data[[3]]+data[[4]]+data[[5]]+data[[6]]+data[[7]],

data[[1]]+data[[2]]+data[[3]]+data[[4]]+data[[5]]+data[[6]]+data[[7]]+data[[8]],

data[[1]]+data[[2]]+data[[3]]+data[[4]]+data[[5]]+data[[6]]+data[[7]]+data[[8]]+data[[9]],

data[[1]]+data[[2]]+data[[3]]+data[[4]]+data[[5]]+data[[6]]+data[[7]]+data[[8]]+data[[9]]+data[[10]]

instead of :-
0
24
29
20
125
140
251

Many thanks for your help. Lea…

Hi Lea,

So I begin by reusing the last result

Table[With[{i = i}, Defer[data[[i]]]], {i, 1, 10}]

{data[[1]], data[[2]], data[[3]], data[[4]], data[[5]], data[[6]], 
 data[[7]], data[[8]], data[[9]], data[[10]]}

I don’t use FoldLIst often so I started with a generic case to test

FoldList[f, 0, Table[With[{i = i}, Defer[data[[i]]]], {i, 1, 10}]]

{0, f[0, data[1]], f[f[0, data[1]], data[[2]]],
f[f[f[0, data[1]], data[[2]]], data[[3]]] ,…}

It seems to work so far. Now we define f to add whatever is passed to it and we obtain the result

FoldList[Plus[##] &, 0, 
 Table[With[{i = i}, Defer[data[[i]]]], {i, 1, 10}]]

Then for data=Range[10] the above would evaluate to

{0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55}

Perfect Ben.
Many thanks, Lea…