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, 21 Sep 2013 19:27:23 +0200accessing the components of a vectorhttps://ask.sagemath.org/question/10386/accessing-the-components-of-a-vector/Is there a command in Sage that allows me to access the individual components of a vector? For example, suppose I've defined a vector like a=vector([1,2,3]). I want a command like "a.1" that returns the first component of the vector, so in this case I would want a.1 to return 1. Is there a command like this in Sage? Thanks!Sat, 21 Sep 2013 19:06:35 +0200https://ask.sagemath.org/question/10386/accessing-the-components-of-a-vector/Answer by minopret for <p>Is there a command in Sage that allows me to access the individual components of a vector? For example, suppose I've defined a vector like a=vector([1,2,3]). I want a command like "a.1" that returns the first component of the vector, so in this case I would want a.1 to return 1. Is there a command like this in Sage? Thanks!</p>
https://ask.sagemath.org/question/10386/accessing-the-components-of-a-vector/?answer=15477#post-id-15477You can use Python sequence indexing syntax, for which the index numbers start at zero: `a=vector([1,2,3]);a[0]` returns 1.Sat, 21 Sep 2013 19:15:28 +0200https://ask.sagemath.org/question/10386/accessing-the-components-of-a-vector/?answer=15477#post-id-15477Comment by strangelove1221 for <p>You can use Python sequence indexing syntax, for which the index numbers start at zero: <code>a=vector([1,2,3]);a[0]</code> returns 1.</p>
https://ask.sagemath.org/question/10386/accessing-the-components-of-a-vector/?comment=16997#post-id-16997Thank you!Sat, 21 Sep 2013 19:27:23 +0200https://ask.sagemath.org/question/10386/accessing-the-components-of-a-vector/?comment=16997#post-id-16997