ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 16 Apr 2019 02:25:03 -0500generate a list of variables with two indiceshttp://ask.sagemath.org/question/46214/generate-a-list-of-variables-with-two-indices/Hi
I would like to make a list of variables with two consecutive indices, example rr_10, rr_21 .. etc
I tried :
n=3
rrL=list(var('rr_%d%d' %i %(i-1)) for i in [1..n])
without success:**not enough arguments for format string**
what is the missing arguments here ? ortolljTue, 16 Apr 2019 02:25:03 -0500http://ask.sagemath.org/question/46214/question about Python assignment of lists; meaning of equals sign; how to save a list?http://ask.sagemath.org/question/44324/question-about-python-assignment-of-lists-meaning-of-equals-sign-how-to-save-a-list/I have a list, then modify it, but want to save the old list to then modify in a different way.
I try to save the original using a different name and =, but it seems the two names are forever linked by the equals sign,
so the modification also changes the original. Why does this happen, and how do I deal with this?
Example:
sage: L1 = [1, 2]
sage: L2 = [3, 4]
sage: L3 = L1
sage: L1
[1, 2]
sage: L2
[3, 4]
sage: L3
[1, 2]
sage: L1.extend(L2)
sage: L1
[1, 2, 3, 4]
sage: L2
[3, 4]
sage: L3
[1, 2, 3, 4]
The same thing happens with "append".
Help please!!!
Note: this does not happen with variables with numerical (not list) values. For example:
sage: a = 4
sage: b = a
sage: a = 5
sage: a
5
sage: b
4
So it seems that the equals sign means two different things: for numbers it is an assignment;
for lists it is an identification. This is driving me crazy. I cannot find it explained anywhere (maybe because it is so "well-known"?)alSun, 18 Nov 2018 08:59:29 -0600http://ask.sagemath.org/question/44324/Please Append 'solve' Help Documentationhttp://ask.sagemath.org/question/32387/please-append-solve-help-documentation/ Hello,
I have been using SAGE for about 2 years, and only now have I finally figured out how to get the 'solve()' function to print out its solutions in plain form (so I can save the answers as variables, which is EXTREMELY important for me).
In order to do this: I had to sift through the help pages for 'solve', Programming -- Data Types (for both Lists and Dictionaries), and Python's official documentation on Lists and Dictionaries; until I finally figured out that you need to use the code:
print( 'listname' [ ' dict # ' ] [ 'var' ])
Now this may seem very elementary to those whom are fluent in Python, but for general users (like me): there is absolutely no clear indication on how to call one or several elements of several Dictionaries inside of a List.
PLEASE append your documentation so that people can actually use the 'solve' function without having to copy and paste the answers because it isn't shown how to properly use the output when 'solution_dict=true'.
(Note: if you're thinking about the 'for' loop example in the help documentation: it's completely useless for someone who needs to select one or more of those solutions & save them as variables).
Thank you.BLU7211Sat, 30 Jan 2016 14:46:43 -0600http://ask.sagemath.org/question/32387/Substitution of a list of variableshttp://ask.sagemath.org/question/10606/substitution-of-a-list-of-variables/I wish substituting a list of variables, without having to substitute them 1 by 1.
Here is an example with an attempt which doesn't work :
sage: V=[var('x_%d' % i) for i in range(10)]; V
[x_0, x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8, x_9]
sage: S=[sum(V),prod(V)]; S
[x_0 + x_1 + x_2 + x_3 + x_4 + x_5 + x_6 + x_7 + x_8 + x_9,
x_0*x_1*x_2*x_3*x_4*x_5*x_6*x_7*x_8*x_9]
sage: for i in range(10):
....: S.subs(V[i]=i)
....:
File "<ipython-input-99-7670392e3358>", line 2
SyntaxError: keyword can't be an expression
How can we do this ?
Sébastien PalcouxSun, 13 Oct 2013 12:44:43 -0500http://ask.sagemath.org/question/10606/