comparison list.rhope @ 150:50c97b448f44

Add Previous method to List
author Mike Pavone <pavone@retrodev.com>
date Wed, 24 Nov 2010 02:28:01 +0000
parents 147dfc703161
children 926b56a43f47
comparison
equal deleted inserted replaced
149:804e48af1027 150:50c97b448f44
96 pos next <- [index]+[1] 96 pos next <- [index]+[1]
97 ,none <- If[[pos next] < [[list]Length]] 97 ,none <- If[[pos next] < [[list]Length]]
98 { 98 {
99 next <- Val[pos next] 99 next <- Val[pos next]
100 } 100 }
101 }
102
103 Previous@List Leaf[list,index:prev,none]
104 {
105 ,none <- If[[index]>[0]]
106 { prev <- [index]-[1] }
101 } 107 }
102 108
103 Blueprint List 109 Blueprint List
104 { 110 {
105 Buffer 111 Buffer
276 { next <- [~]+[[list]Right Offset >>] } 282 { next <- [~]+[[list]Right Offset >>] }
277 } 283 }
278 } 284 }
279 } 285 }
280 286
287 Previous@List[list,index:prev,none]
288 {
289 If[[index] <= [[list]Offset >>]]
290 {
291 prev,none <- [[list]Left >>]Previous[index]
292 }{
293 If[[index] <= [[list]Right Offset >>]]
294 {
295 pos prev <- [index]-[1]
296 If[[pos prev] < [[[[list]Buffer >>]Length]+[[list]Offset >>]]]
297 { prev <- Val[pos prev] }
298 { prev <- [[[[list]Buffer >>]Length]+[[list]Offset >>]]-[1] }
299 }{
300 [[list]Right >>]Previous[[index]-[[list]Right Offset >>]]
301 { prev <- [~]+[[list]Right Offset >>] }
302 { prev <- [[[[list]Buffer >>]Length]+[[list]Offset >>]]-[1] }
303 }
304 }
305 }
306
281 New Like@List[in:out] 307 New Like@List[in:out]
282 { 308 {
283 out <- List[] 309 out <- List[]
284 } 310 }
285 311