File tree Expand file tree Collapse file tree 2 files changed +35
-5
lines changed Expand file tree Collapse file tree 2 files changed +35
-5
lines changed Original file line number Diff line number Diff line change @@ -46,8 +46,12 @@ function ==(x::Sequence,y::Sequence)
46
46
end
47
47
48
48
function Base. getindex (S:: Sequence , ii:: Int )
49
- k = length (S. items) - S. preperiod
50
- return S. items[mod1 (ii- S. preperiod,k)]
49
+ if ii <= S. preperiod
50
+ return S. items[ii]
51
+ else
52
+ k = length (S. items) - S. preperiod
53
+ return S. items[mod1 (ii- S. preperiod,k)]
54
+ end
51
55
end
52
56
53
57
function Base. getindex (S:: Sequence , I:: UnitRange )
@@ -127,6 +131,16 @@ function divisors(n)
127
131
return sort (d)
128
132
end
129
133
134
+ function agrees (K:: Sequence ,str:: String )
135
+ for (ii,item) in enumerate (str)
136
+ if item != = K[ii]
137
+ return false
138
+ end
139
+ end
140
+ return true
141
+ end
130
142
131
-
143
+ function prepend (K:: Sequence ,thing)
144
+ return Sequence {Char} (pushfirst! (copy (K. items),thing),K. preperiod+ 1 )
145
+ end
132
146
Original file line number Diff line number Diff line change @@ -9,12 +9,28 @@ abstract type AbstractHubbardTree
9
9
end
10
10
11
11
struct HubbardTree <: AbstractHubbardTree
12
- zero:: Sequence
12
+ zero:: Sequence # Rename this to critical? Remove it and use H["*"] everywhere?
13
13
adj:: Dict{Sequence,Set{Sequence}}
14
14
end
15
15
16
+ function Base. getindex (H:: HubbardTree , str:: String )
17
+ list = []
18
+ for (K,neighbors) in pairs (H. adj)
19
+ if agrees (K,str)
20
+ newneighbors = []
21
+ for N in neighbors
22
+ if agrees (N,str)
23
+ push! (newneighbors,N)
24
+ end
25
+ end
26
+ push! (list,Pair (K,newneighbors))
27
+ end
28
+ end
29
+ return Dict (list)
30
+ end
31
+
16
32
function HubbardTree (K:: Sequence{Char} )
17
- starK = Sequence {Char} ( pushfirst! ( copy (K . items) ,' *' ),K . preperiod + 1 )
33
+ starK = prepend (K ,' *' )
18
34
# We begin with the critical orbit
19
35
markedpoints = copy (orbit (starK). items)
20
36
You can’t perform that action at this time.
0 commit comments