Thanks Marshall. I have thought about that as well.
Since I want to optimize time. I want to see if your method is faster
then a for loop. However, I run into something puzzling:

vector( [k for k in range(10)]) results in an error. Sage compliant
about

TypeError: unable to find a common ring for all elements

But if you check each element of the list, I got <type 'int'>

So why SAGE is complaining?

On Oct 19, 7:27 am, Marshall Hampton <[EMAIL PROTECTED]> wrote:
> Another option is to convert your list to a vector, and then convert
> it back.  This is more awkward for a single operation but if you are
> doing lots of vector addition and scalar multiplication it can be the
> way to go.
> I.e. you can do:
>
> sage: a = [3,4]
> sage: a = list(2*vector(a))
> sage: a
> [6, 8]
>
> -M. Hampton
>
> On Oct 19, 1:15 am, Robert Bradshaw <[EMAIL PROTECTED]>
> wrote:
>
> > On Oct 18, 2008, at 10:14 PM, Alex Ghitza wrote:
>
> > > Hmmm.  As far as I know you can use _ as a placeholder for a
> > > variable, and it's meant for this kind of use (where you don't
> > > really want to introduce a new variable name).  It's strange that
> > > it doesn't work for you.  Can you post the error message that you get?
>
> > Actually, _ is an actual variable, though personally I find it a bit
> > harder to read than a normal letter. The one special thing about it
> > (in ipython at least) is that it constantly gets reassigned to the
> > last returned value, e.g.
>
> > sage: 1+2
> > 3
> > sage: _
> > 3
>
> > - Robert
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to