Message Boards Message Boards

0
|
3483 Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Avoid problem with iterator?

Posted 6 years ago

Hello, I am trying to get {Subscript[a, 0], Subscript[a, 1], Subscript[a, x], Subscript[a, x+1]} using the table as follows,

Table[Subscript[a, p], {p, {0, 1, x, x + 1}}  ]

But it does not return the last value of p.

This is the output: `{Subscript[a, 0], Subscript[a, 1], Subscript[a, x], 1}

Any help? Thank you`

POSTED BY: Shahzeb Kamal
3 Replies
Posted 6 years ago

Hey, Thanks. Whenever i start a new Kernel session then it works, however i can't reuse a variable in the same kernel (mathematica is not holding a variable somehow)! I am using 10.4 by the way. Best wishes, Shahzeb

POSTED BY: Shahzeb Kamal

Hi,

I cannot reproduce that in any of the recent versions of MMA.

Table[Subscript[a, p], {p, {0, 1, x, x + 1}}]

gives

{Subscript[a, 0], Subscript[a, 1], Subscript[a, x], Subscript[a, 1 + x]}

What version are you using? Can you start a new Kernel session?

Best wishes, Marco

PS: Sorry, the last post only showed up after I had submitted.... Sometimes there is a long delay...

POSTED BY: Marco Thiel

What version are you using? It works ok in 11.2

In[1]:= Table[Subscript[a, p], {p, {0, 1, x, x + 1}}]

Out[1]= {Subscript[a, 0], Subscript[a, 1], Subscript[a, x], \
Subscript[a, 1 + x]}
POSTED BY: Frank Kampas
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract