#8490: Bad behavior of is_square_free for Words
--------------------------------------------------+-------------------------
Reporter: vdelecroix | Owner: vdelecroix
Type: defect | Status: needs_review
Priority: major | Milestone: sage-4.4.2
Component: combinatorics | Keywords: word
Author: Vincent Delecroix, Sébastien Labbé | Upstream: N/A
Reviewer: Mike Hansen | Merged:
Work_issues: |
--------------------------------------------------+-------------------------
Comment(by slabbe):
Replying to [comment:7 ncohen]:
> Hello !! This patch is finem except for a small unimportant thing which
bothered me :
>
> {{{
> for end in xrange(start+3, L+1, 3):
> }}}
>
> Why go up to L+1 when the last letter is L-1 ?
First, xrange returns a left-closed and right-open interval. Hence, one
needs to write something like `xrange(0,L+1)` if one wants to go up to `L`
:
{{{
sage: list(xrange(0,5))
[0, 1, 2, 3, 4]
}}}
Second, the variable `end` is not used to get a specific item in self but
for slicing self. Hence, if one wants to consider all the slicing
possibilities, the variable `end` must take the last possible value `L`:
{{{
sage: list(xrange(0,5)) [2:5] #is good
[2, 3, 4]
sage: list(xrange(0,5)) [2:4] #forgets the last letter
[2, 3]
}}}
Hence, your patch is strange in the sense that doctests should not pass!
> The algorithm is still correct as
>
> {{{
> Word("abc")[:50000]
> }}}
>
> raises no exception, but as there is no reason to....
We made the choice of following the Python behavior for slices that goes
too far:
{{{
sage: L = range(10)
sage: L
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
sage: L[:100]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
}}}
Sébastien
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8490#comment:9>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.