Dear geo909 (I can't believe what some people call their children!) Try: sage: [1,1,2,1,3] in LyndonWords() True sage: [2,1,3,2] in LyndonWords() False
Andrew On Wednesday, 11 December 2013 16:22:42 UTC+1, geo909 wrote: > > Hi all, > > From wikipedia: > > *In mathematics, in the areas of combinatorics and computer > science, a Lyndon word is a string that is strictly smaller in > lexicographic order than all of its rotations. Lyndon words are named after > mathematician Roger Lyndon, who introduced them in 1954, calling them > standard lexicographic sequences* > > For example [1,1,2,1,3] is a Lyndon word, but [1,3,1,1,2] is not. > > I need to check as efficiently as possible if a given integer sequence is > a Lyndon word or not. Is there such an option in sage? > I check the section for Lyndon words in the > manual<http://www.sagemath.org/doc/reference/combinat/sage/combinat/lyndon_word.html>but > apparently the only way one can check something like that, is in a > situation like so: > > sage: LyndonWord([2,1,2,3])Traceback (most recent call last):...ValueError: > Not a Lyndon word >> >> > Is this my only option for checking if something is a Lyndon word? This > suggests that there is inherently some check in this > function, but I do not want to use a ValueError for that.. > > Any advice? > > Thank you in advance > -- 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 sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.