# Ticket #12997(closed defect: fixed)

Opened 12 months ago

## LyndonWords from composition beginning by 0's

Reported by: Owned by: Adrien sage-combinat minor sage-5.9 combinatorics lyndon words, sage-combinat, days45 slabbe, saliola N/A Travis Scrimshaw, Frédéric Chapoton Adrien Brochier sage-5.9.beta1

LyndonWords, when applied to a composition starting with 0's, gives a wrong result, e.g.:

```for w in LyndonWords(list([0,1])):
print w
```

return 1 instead of 2, and in a similar vein

```for w in LyndonWords(list([0,2])):
print w
```

return '12'

The problem is that necklace._sfc() ignores 0's at the begining of a list.

A modified lyndon_word.py file which fix the problem is attached.

Apply:

## Change History

### comment:1 Changed 12 months ago by Adrien

• Description modified (diff)

### Changed 12 months ago by Adrien

Modified lyndon_word.py

diff

### comment:2 Changed 12 months ago by saliola

You can follow Sébastien's guide on  http://thales.math.uqam.ca/~labbes/Sage/how-to-contribute/ How to contribute to Sage (especially steps 15 to 17).

### comment:4 Changed 12 months ago by Adrien

• Status changed from new to needs_review

patch

### comment:6 Changed 10 months ago by Adrien

• Authors set to Adrien Brochier

### comment:7 Changed 7 months ago by tscrim

• Status changed from needs_review to needs_work
• Reviewers set to Travis Scrimshaw

Please add some tests to the __iter__ method showing the ticket has been fixed such as:

```TESTS:

Showing :trac:`12997` is fixed::

sage: LyndonWords([0,1]).list()
[word: 2]
sage: LyndonWords([0,2]).list()
[]
sage: LyndonWords([0,0,1,0,1]).list()
[word: 35]
```

Thanks,
Travis

### comment:8 Changed 3 months ago by tscrim

• Keywords sage-combinat, days45 added; sage-combinat removed
• Status changed from needs_work to needs_review

I've attached the review patch which adds the doctests and tweaks the code format. Could someone give this a quick second review please?

Thanks,
Travis

### comment:9 Changed 2 months ago by chapoton

• Status changed from needs_review to positive_review
• Description modified (diff)

Ok, this looks good to me.

I have added a patch to change the "raise" to python3 syntax

positive review

### comment:10 Changed 2 months ago by chapoton

• Reviewers changed from Travis Scrimshaw to Travis Scrimshaw, Frédéric Chapoton

Thanks Frederic!

### comment:12 Changed 2 months ago by jdemeyer

• Status changed from positive_review to closed
• Resolution set to fixed
• Merged in set to sage-5.9.beta1
Note: See TracTickets for help on using tickets.