ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 18 Oct 2014 12:49:06 +0200How to take multiple outputs of a command and use them one by one laterhttps://ask.sagemath.org/question/24508/how-to-take-multiple-outputs-of-a-command-and-use-them-one-by-one-later/ Hi,
This is what I am trying to achieve while using Sage worksheet interface.
Assume that I wrote a code and it gave, for example, for each i in a range of lists, list[0]. (First element of each list) So I have multiple outputs. Now I want to use these outputs, I want the system to consider them as a list, and take iterative combinations of elements of it. Can I do that, and how?
Fri, 17 Oct 2014 07:09:55 +0200https://ask.sagemath.org/question/24508/how-to-take-multiple-outputs-of-a-command-and-use-them-one-by-one-later/Comment by vdelecroix for <p>Hi,</p>
<p>This is what I am trying to achieve while using Sage worksheet interface.</p>
<p>Assume that I wrote a code and it gave, for example, for each i in a range of lists, list[0]. (First element of each list) So I have multiple outputs. Now I want to use these outputs, I want the system to consider them as a list, and take iterative combinations of elements of it. Can I do that, and how?</p>
https://ask.sagemath.org/question/24508/how-to-take-multiple-outputs-of-a-command-and-use-them-one-by-one-later/?comment=24512#post-id-24512hello, could you describe more precisely what you want to do? Or even better, put a simple version of your code of the first function...Fri, 17 Oct 2014 16:44:23 +0200https://ask.sagemath.org/question/24508/how-to-take-multiple-outputs-of-a-command-and-use-them-one-by-one-later/?comment=24512#post-id-24512Answer by calc314 for <p>Hi,</p>
<p>This is what I am trying to achieve while using Sage worksheet interface.</p>
<p>Assume that I wrote a code and it gave, for example, for each i in a range of lists, list[0]. (First element of each list) So I have multiple outputs. Now I want to use these outputs, I want the system to consider them as a list, and take iterative combinations of elements of it. Can I do that, and how?</p>
https://ask.sagemath.org/question/24508/how-to-take-multiple-outputs-of-a-command-and-use-them-one-by-one-later/?answer=24517#post-id-24517I usually do this using a `for` loop. For example,
L=[[1,2],[3,4],[5,6]]
# overly simple example function
f(x)=x^2
for entry in L:
#your code to run here
f(entry[0])Sat, 18 Oct 2014 12:49:06 +0200https://ask.sagemath.org/question/24508/how-to-take-multiple-outputs-of-a-command-and-use-them-one-by-one-later/?answer=24517#post-id-24517