Thanks! That makes sense now that I see it. I thought I was going insane.
Thanks also for showing preparse.
On Monday, May 9, 2016 at 9:38:31 PM UTC-4, D. S. McNeil wrote:
>
> Not scoping, typing.
>
> When you do i+1, this is preparsed into
>
> sage: preparse('[len(top_points(i+1)) for i in range(2,10)]')
> '[len(top_points(i+Integer(1))) for i in range(Integer(2),Integer(10))]'
>
> and the addition means that top_points is passed not a Python int, but a
> Sage Integer, and your divisions aren't Python 2 truncating division.
>
> To avoid this, you could use srange:
>
> sage: [len(top_points(i)) for i in range(3,11)]
> [5, 5, 5, 5, 5, 5, 5, 5]
> sage: [len(top_points(i)) for i in srange(3,11)]
> [30, 55, 91, 140, 204, 285, 385, 506]
>
> or the `..` notation:
>
> sage: [len(top_points(i)) for i in (3..10)]
> [30, 55, 91, 140, 204, 285, 385, 506]
>
> or anything which makes sure that you're not dividing an int by an int.
>
>
> Doug
>
>
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.