how to use the following output of a command directly in another command?
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
How to use Row[Table[B[i],0,i,i,0,2],","]
directly in Do
command? I mean that the following command
Row[Table[B[i],0,i,i,0,2],","]
gives
B[0], 0, 0,B[1], 0, 1,B[2],0,2
But, the following command returns the error
"Do::nliter: Non-list iterator Row[Table[B[i], 0, i, i, 0, 2], ,] at position 2 does not evaluate to a real numeric value."
Do[Print[B[0]+B[1]+B[2]],Row[Table[B[i],0,i,i,0,2],","]]
Of course, one can type instead by hand the following:
Do[Print[B[0]+B[1]+B[2]],B[0],0,0,B[1],0,1,B[2],0,2]
But, I feel that typing an output by hand again is not really an optimal method.
list-manipulation row do
New contributor
add a comment |Â
up vote
3
down vote
favorite
How to use Row[Table[B[i],0,i,i,0,2],","]
directly in Do
command? I mean that the following command
Row[Table[B[i],0,i,i,0,2],","]
gives
B[0], 0, 0,B[1], 0, 1,B[2],0,2
But, the following command returns the error
"Do::nliter: Non-list iterator Row[Table[B[i], 0, i, i, 0, 2], ,] at position 2 does not evaluate to a real numeric value."
Do[Print[B[0]+B[1]+B[2]],Row[Table[B[i],0,i,i,0,2],","]]
Of course, one can type instead by hand the following:
Do[Print[B[0]+B[1]+B[2]],B[0],0,0,B[1],0,1,B[2],0,2]
But, I feel that typing an output by hand again is not really an optimal method.
list-manipulation row do
New contributor
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
How to use Row[Table[B[i],0,i,i,0,2],","]
directly in Do
command? I mean that the following command
Row[Table[B[i],0,i,i,0,2],","]
gives
B[0], 0, 0,B[1], 0, 1,B[2],0,2
But, the following command returns the error
"Do::nliter: Non-list iterator Row[Table[B[i], 0, i, i, 0, 2], ,] at position 2 does not evaluate to a real numeric value."
Do[Print[B[0]+B[1]+B[2]],Row[Table[B[i],0,i,i,0,2],","]]
Of course, one can type instead by hand the following:
Do[Print[B[0]+B[1]+B[2]],B[0],0,0,B[1],0,1,B[2],0,2]
But, I feel that typing an output by hand again is not really an optimal method.
list-manipulation row do
New contributor
How to use Row[Table[B[i],0,i,i,0,2],","]
directly in Do
command? I mean that the following command
Row[Table[B[i],0,i,i,0,2],","]
gives
B[0], 0, 0,B[1], 0, 1,B[2],0,2
But, the following command returns the error
"Do::nliter: Non-list iterator Row[Table[B[i], 0, i, i, 0, 2], ,] at position 2 does not evaluate to a real numeric value."
Do[Print[B[0]+B[1]+B[2]],Row[Table[B[i],0,i,i,0,2],","]]
Of course, one can type instead by hand the following:
Do[Print[B[0]+B[1]+B[2]],B[0],0,0,B[1],0,1,B[2],0,2]
But, I feel that typing an output by hand again is not really an optimal method.
list-manipulation row do
list-manipulation row do
New contributor
New contributor
edited 9 mins ago
kglr
160k8184384
160k8184384
New contributor
asked 20 mins ago
veo
1234
1234
New contributor
New contributor
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
3
down vote
What you actually want is to create a Sequence
from the Table
to be used as your iterators.
You can do this with
Do[Print[B[0] + B[1] + B[2]], Sequence @@ Table[B[i], 0, i, i, 0, 2] //
Evaluate]
(*0
1
2
1
2
3*)
Or, so you don't have to force evaluation,
Do[Print[B[0] + B[1] + B[2]], ##] & @@ Table[B[i], 0, i, i, 0, 2]
add a comment |Â
up vote
1
down vote
Do[Print[B[0] + B[1] + B[2]],
Evaluate[Sequence @@ First@ Row[Table[B[i], 0, i, i, 0, 2], ","]]]
or
row = Row[Table[B[i], 0, i, i, 0, 2], ","];
Do[Print[B[0] + B[1] + B[2]], Evaluate[Sequence @@ row[[1]]]]
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
What you actually want is to create a Sequence
from the Table
to be used as your iterators.
You can do this with
Do[Print[B[0] + B[1] + B[2]], Sequence @@ Table[B[i], 0, i, i, 0, 2] //
Evaluate]
(*0
1
2
1
2
3*)
Or, so you don't have to force evaluation,
Do[Print[B[0] + B[1] + B[2]], ##] & @@ Table[B[i], 0, i, i, 0, 2]
add a comment |Â
up vote
3
down vote
What you actually want is to create a Sequence
from the Table
to be used as your iterators.
You can do this with
Do[Print[B[0] + B[1] + B[2]], Sequence @@ Table[B[i], 0, i, i, 0, 2] //
Evaluate]
(*0
1
2
1
2
3*)
Or, so you don't have to force evaluation,
Do[Print[B[0] + B[1] + B[2]], ##] & @@ Table[B[i], 0, i, i, 0, 2]
add a comment |Â
up vote
3
down vote
up vote
3
down vote
What you actually want is to create a Sequence
from the Table
to be used as your iterators.
You can do this with
Do[Print[B[0] + B[1] + B[2]], Sequence @@ Table[B[i], 0, i, i, 0, 2] //
Evaluate]
(*0
1
2
1
2
3*)
Or, so you don't have to force evaluation,
Do[Print[B[0] + B[1] + B[2]], ##] & @@ Table[B[i], 0, i, i, 0, 2]
What you actually want is to create a Sequence
from the Table
to be used as your iterators.
You can do this with
Do[Print[B[0] + B[1] + B[2]], Sequence @@ Table[B[i], 0, i, i, 0, 2] //
Evaluate]
(*0
1
2
1
2
3*)
Or, so you don't have to force evaluation,
Do[Print[B[0] + B[1] + B[2]], ##] & @@ Table[B[i], 0, i, i, 0, 2]
edited 6 mins ago
answered 12 mins ago
That Gravity Guy
40125
40125
add a comment |Â
add a comment |Â
up vote
1
down vote
Do[Print[B[0] + B[1] + B[2]],
Evaluate[Sequence @@ First@ Row[Table[B[i], 0, i, i, 0, 2], ","]]]
or
row = Row[Table[B[i], 0, i, i, 0, 2], ","];
Do[Print[B[0] + B[1] + B[2]], Evaluate[Sequence @@ row[[1]]]]
add a comment |Â
up vote
1
down vote
Do[Print[B[0] + B[1] + B[2]],
Evaluate[Sequence @@ First@ Row[Table[B[i], 0, i, i, 0, 2], ","]]]
or
row = Row[Table[B[i], 0, i, i, 0, 2], ","];
Do[Print[B[0] + B[1] + B[2]], Evaluate[Sequence @@ row[[1]]]]
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Do[Print[B[0] + B[1] + B[2]],
Evaluate[Sequence @@ First@ Row[Table[B[i], 0, i, i, 0, 2], ","]]]
or
row = Row[Table[B[i], 0, i, i, 0, 2], ","];
Do[Print[B[0] + B[1] + B[2]], Evaluate[Sequence @@ row[[1]]]]
Do[Print[B[0] + B[1] + B[2]],
Evaluate[Sequence @@ First@ Row[Table[B[i], 0, i, i, 0, 2], ","]]]
or
row = Row[Table[B[i], 0, i, i, 0, 2], ","];
Do[Print[B[0] + B[1] + B[2]], Evaluate[Sequence @@ row[[1]]]]
edited 5 mins ago
answered 12 mins ago
kglr
160k8184384
160k8184384
add a comment |Â
add a comment |Â
veo is a new contributor. Be nice, and check out our Code of Conduct.
veo is a new contributor. Be nice, and check out our Code of Conduct.
veo is a new contributor. Be nice, and check out our Code of Conduct.
veo is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f181912%2fhow-to-use-the-following-output-of-a-command-directly-in-another-command%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password