Mercurial > repos > rhope
comparison list.rhope @ 76:004f0fc8941f
Fix list implementation
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 07 Jul 2010 00:36:59 -0400 |
parents | 0083b2f7b3c7 |
children | e73a93fb5de1 |
comparison
equal
deleted
inserted
replaced
75:0083b2f7b3c7 | 76:004f0fc8941f |
---|---|
84 out <- [list]Set[index, val] | 84 out <- [list]Set[index, val] |
85 } | 85 } |
86 | 86 |
87 First@List Leaf[list:out,none] | 87 First@List Leaf[list:out,none] |
88 { | 88 { |
89 Print["First@List Leaf"] | |
90 [[list]Buffer >>]Index[0] | 89 [[list]Buffer >>]Index[0] |
91 { out <- 0 } | 90 { out <- 0 } |
92 { none <- Yes } | 91 { none <- Yes } |
93 } | 92 } |
94 | 93 |
95 Next@List Leaf[list,index:next,none] | 94 Next@List Leaf[list,index:next,none] |
96 { | 95 { |
97 Print["Next@List Leaf"] | |
98 { Print[index] | |
99 { | |
100 pos next <- [index]+[1] | 96 pos next <- [index]+[1] |
101 ,none <- If[[pos next] < [[list]Length]] | 97 ,none <- If[[pos next] < [[list]Length]] |
102 { | 98 { |
103 next <- Val[pos next] | 99 next <- Val[pos next] |
104 } | 100 } |
105 }} | |
106 } | 101 } |
107 | 102 |
108 Blueprint List | 103 Blueprint List |
109 { | 104 { |
110 Buffer | 105 Buffer |
180 | 175 |
181 out <- [[[list]Right <<[nright] | 176 out <- [[[list]Right <<[nright] |
182 ]Length <<[ [[list]Length >>]+[1] ] | 177 ]Length <<[ [[list]Length >>]+[1] ] |
183 ]Right Offset <<[nroffset] | 178 ]Right Offset <<[nroffset] |
184 }{ | 179 }{ |
185 | |
186 out <- [[[list]Right <<[ [[list]Right >>]Set[0, val] ] | 180 out <- [[[list]Right <<[ [[list]Right >>]Set[0, val] ] |
187 ]Right Offset <<[index] | 181 ]Right Offset <<[index] |
188 ]Length <<[ [[list]Length >>]+[1] ] | 182 ]Length <<[ [[list]Length >>]+[1] ] |
189 } | 183 } |
190 }{ | 184 }{ |
228 { | 222 { |
229 If[[[list]Right Offset >>]>[index]] | 223 If[[[list]Right Offset >>]>[index]] |
230 { | 224 { |
231 out <- [list]Set[index, val] | 225 out <- [list]Set[index, val] |
232 }{ | 226 }{ |
233 out,did'nt set <- [list]_Right Set[[index]-[[list]Right Offset >>], val] | 227 out,didn't set <- [[list]Right >>]_Right Set[[index]-[[list]Right Offset >>], val] |
234 } | 228 } |
235 } | 229 } |
236 | 230 |
237 Last@List[list:out,none] | 231 Last@List[list:out,none] |
238 { | 232 { |
249 out <- [list]Set[index, val] | 243 out <- [list]Set[index, val] |
250 } | 244 } |
251 | 245 |
252 First@List[list:out,none] | 246 First@List[list:out,none] |
253 { | 247 { |
254 Print["First@List"] | |
255 If[[[list]Left >>]Length] | 248 If[[[list]Left >>]Length] |
256 { | 249 { |
257 out <- [[list]Left >>]First | 250 out <- [[list]Left >>]First |
258 }{ | 251 }{ |
259 out <- [list]Offset >> | 252 out <- [list]Offset >> |
260 } | 253 } |
261 } | 254 } |
262 | 255 |
263 Next@List[list,index:next,none] | 256 Next@List[list,index:next,none] |
264 { | 257 { |
265 Print["Next@List"] | |
266 { Print[index] | |
267 { Print[[list]Offset >>] | |
268 { | |
269 If[[index] < [[[list]Offset >>]-[1]]] | 258 If[[index] < [[[list]Offset >>]-[1]]] |
270 { | 259 { |
271 Print["Left"] | |
272 next <- [[list]Left >>]Next[index] {} | 260 next <- [[list]Left >>]Next[index] {} |
273 { next <- Offset >>[list] } | 261 { next <- Offset >>[list] } |
274 }{ | 262 }{ |
275 If[[index] < [[list]Right Offset >>]] | 263 If[[index] < [[list]Right Offset >>]] |
276 { | 264 { |
277 Print["Middle"] | |
278 pos next <- [index]+[1] | 265 pos next <- [index]+[1] |
279 If[[pos next] < [[[[list]Buffer >>]Length >>]+[[list]Offset >>]]] | 266 If[[pos next] < [[[[list]Buffer >>]Length >>]+[[list]Offset >>]]] |
280 { | 267 { |
281 next <- Val[pos next] | 268 next <- Val[pos next] |
282 }{ | 269 }{ |
283 Print["Middle done going Right instead"] | |
284 ,none <- [[list]Right >>]First | 270 ,none <- [[list]Right >>]First |
285 { next <- [~]+[[list]Right Offset >>] } | 271 { next <- [~]+[[list]Right Offset >>] } |
286 { | |
287 Print["First on right returned none"] | |
288 { Print[[[list]Right >>]Length] } | |
289 } | |
290 } | 272 } |
291 }{ | 273 }{ |
292 Print["right"] | |
293 ,none <- [[list]Right >>]Next[[index]-[[list]Right Offset >>]] | 274 ,none <- [[list]Right >>]Next[[index]-[[list]Right Offset >>]] |
294 { next <- [~]+[[list]Right Offset >>] } | 275 { next <- [~]+[[list]Right Offset >>] } |
295 } | 276 } |
296 } | 277 } |
297 }}} | 278 } |
298 } | 279 |
299 |