#8739: Addition of Kolakoski word
-----------------------------+----------------------------------------------
Reporter: abmasse | Owner: sage-combinat
Type: enhancement | Status: needs_work
Priority: minor | Milestone: sage-5.0
Component: combinatorics | Keywords: Kolakoski, words
Author: | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
-----------------------------+----------------------------------------------
Changes (by abmasse):
* status: needs_info => needs_work
Comment:
Replying to [comment:3 ncohen]:
> Looks nice ! :-)
>
> Several remarks though, that I do not dare implement myself :
>
> * You specify in the private function `_KolakoskiWord_iterator` that the
alphabet must be composed of two positive integers, but not in
`KolakoskiWord`. Are the users supposed to know they should not use
anything else ? (honest question, Words are not my field at all even if I
can understand the construction :-) )
>
You're right, I forgot to document it in the main function.
> * You write `current_letter = bar(w[-1])`, thus accessing the -1'th
element. What about writing `current_letter = bar(current_letter)` at the
end of the loop ?
>
Right again. I think I did it to avoid initializing `current_letter` in
the basis, but this is less readable and we're not sure if `w[-1]` is
performed in constant time. Is it ?
> * You maintain a variable named `current_run`, and keep in memory a list
of letters you already used (`w[:current_run]`). Wouldn't it be easier to
forget about the current run variable, and just use your list as a queue
with append() and pop(0) operations ? :-)
>
Once again right. When I first wrote the function, I did as you say, but
there was a mistake I couldn't solve. Then I simplified by keeping the
complete prefix of the word, but now that it is working, it shouldn't be
hard to modify.
> As I did not know the construction, I thought a bit about how I would
write the algorithm and could not find any way to do it without keeping a
lot of things in memory, what your `w` variable actually contains. Do you
know if there exists a way to get rid of it ? I'm just being curious :-)
>
I feel it would be hard, but I don't have any proof. On the other hand, I
can get rid of all values of `w` that have already been read by the
`current_run` cursor, as you mentionned above.
> Nathann
Thank you for your comment. I'll upload a new patch soon.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8739#comment:4>
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.