Mike Hansen wrote: > Hi Stan, > > You should use Python's list comprehensions to do that: > > sage: f = 2*x^3+1 > sage: v = [1,2,3] > sage: [f(x=a) for a in v] > [3, 17, 55] > > or you could do > > sage: map(f, v) > [3, 17, 55]
The question was: Is there an easy way of performing operations on arrays or lists without defining loops? The answer is: no, not really. Functions don't automatically thread themselves over lists. List comprehensions and maps provide a simple way to loop over a set, though. Personally, I think it's generally a good thing that functions don't automatically thread themselves over lists. Jason --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---