# HG changeset patch # User Mike Pavone # Date 1290565681 0 # Node ID 50c97b448f44bf41048502b5b07759924cac8028 # Parent 804e48af102705119e019ed1d568f7ab21f8caf1 Add Previous method to List diff -r 804e48af1027 -r 50c97b448f44 list.rhope --- a/list.rhope Mon Nov 22 20:38:03 2010 +0000 +++ b/list.rhope Wed Nov 24 02:28:01 2010 +0000 @@ -100,6 +100,12 @@ } } +Previous@List Leaf[list,index:prev,none] +{ + ,none <- If[[index]>[0]] + { prev <- [index]-[1] } +} + Blueprint List { Buffer @@ -278,6 +284,26 @@ } } +Previous@List[list,index:prev,none] +{ + If[[index] <= [[list]Offset >>]] + { + prev,none <- [[list]Left >>]Previous[index] + }{ + If[[index] <= [[list]Right Offset >>]] + { + pos prev <- [index]-[1] + If[[pos prev] < [[[[list]Buffer >>]Length]+[[list]Offset >>]]] + { prev <- Val[pos prev] } + { prev <- [[[[list]Buffer >>]Length]+[[list]Offset >>]]-[1] } + }{ + [[list]Right >>]Previous[[index]-[[list]Right Offset >>]] + { prev <- [~]+[[list]Right Offset >>] } + { prev <- [[[[list]Buffer >>]Length]+[[list]Offset >>]]-[1] } + } + } +} + New Like@List[in:out] { out <- List[]