1 | initial version |
Pre-parsing is what happened here! Note that
preparse(fermat(5))
almost certainly will get you something with Integer(5)
, but the iterator (1..9)
only consists of Python int
s, and apparently the program never actually explicitly coerces to Sage integers but manages to have int
output all the way through. Surprising but you can probably trace it step by step.
If you use srange(1,10)
that should work, and maybe even [1..9]
would give Sage integers? I can't test this right now as I'm not on a high-power situation and wifi is spotty on the train, but try these solutions.
2 | No.2 Revision |
Pre-parsing Old answer:
Preparsing is what happened
here! Note thathere ...preparse(fermat(5))
almost certainly will That was wrong. The problem is that fermat(1) ends up doing sum([]) which defaults to the Python summation, not Sage summation, and so you just get you something with the Integer(5)
, but iterator Python result of (1..9)
only consists Python a sum, which is the int
s, and apparently program never actually explicitly coerces int zero (as an empty sum). I'm not 100% sure how to Sage integers but manages to have fix that but you int
output all the way through. Surprising can probably trace it step by step.could at the very least special-case it. I don't think srange would help here.
If you use srange(1,10)
that should work, and maybe even [1..9]
would give Sage integers? I can't test this right now as I'm not on a high-power situation and wifi is spotty on the train, but try these solutions.