ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 27 Feb 2016 11:07:19 -0600Integer not iterablehttp://ask.sagemath.org/question/32676/integer-not-iterable/ Not sure if this was asked before. I've been going through the Sage and Python tutorials for the past 3 weeks as I worked out that I'll eventually have to learn at least some Python so to get what I need from Sage. So far so good,
But this one escapes me. The Sage tutorial refers to this example in The Python library:
map(mul, [0, 1, 2, 3], [10, 20, 30, 40]) which is supposed to yield [0, 20, 60, 120]
However, I keep getting
...
...
TypeError: 'sage.rings.integer.Integer' object is not iterable
What's causing this?
Hope someone can help
Gerry
Fri, 26 Feb 2016 19:09:54 -0600http://ask.sagemath.org/question/32676/integer-not-iterable/Answer by gerry_chuck for <p>Not sure if this was asked before. I've been going through the Sage and Python tutorials for the past 3 weeks as I worked out that I'll eventually have to learn at least some Python so to get what I need from Sage. So far so good, </p>
<p>But this one escapes me. The Sage tutorial refers to this example in The Python library:</p>
<p>map(mul, [0, 1, 2, 3], [10, 20, 30, 40]) which is supposed to yield [0, 20, 60, 120]</p>
<p>However, I keep getting
...
...
TypeError: 'sage.rings.integer.Integer' object is not iterable</p>
<p>What's causing this?</p>
<p>Hope someone can help
Gerry</p>
http://ask.sagemath.org/question/32676/integer-not-iterable/?answer=32677#post-id-32677Yep, silly me, worked it out. Few lines below on the same page it says to enter the following command:
from operator import mul
Hope someone who uses the same approch in Learning sage finds this useful.
Gerry
Fri, 26 Feb 2016 19:16:53 -0600http://ask.sagemath.org/question/32676/integer-not-iterable/?answer=32677#post-id-32677Comment by ndomes for <p>Yep, silly me, worked it out. Few lines below on the same page it says to enter the following command:</p>
<p>from operator import mul</p>
<p>Hope someone who uses the same approch in Learning sage finds this useful.</p>
<p>Gerry</p>
http://ask.sagemath.org/question/32676/integer-not-iterable/?comment=32682#post-id-32682In conjunction with map() I would prefer an anonymous function (lambda function):
map(lambda x,y:x*y, [0, 1, 2, 3], [10, 20, 30, 40])Sat, 27 Feb 2016 11:07:19 -0600http://ask.sagemath.org/question/32676/integer-not-iterable/?comment=32682#post-id-32682