# HG changeset patch # User Mike Pavone # Date 1276663013 0 # Node ID 1bfcf5f8fa69e014ce54288fe7b037a97a19ab12 # Parent d0ce696786cce0bc475f65ed480b5c9acd4201d0 Beginning of List implementation diff -r d0ce696786cc -r 1bfcf5f8fa69 list.rhope --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/list.rhope Wed Jun 16 04:36:53 2010 +0000 @@ -0,0 +1,78 @@ + +Blueprint List Leaf +{ + Buffer +} + +Index@List Leaf[list,index:out,not found] +{ + out, not found <- [[list]Buffer >>]Index[index] +} + +Set@List Leaf[list,index,value:out] +{ + If[[index] < [0]] + { + }{ + If[[index] > [[[list]Buffer >>]Length >>]] + { + makeleft <- Yes + }{ + If[[index] > [7]] + { + makeleft <- Yes + }{ + out <- [list]Buffer <<[ [[list]Buffer >>]Set[index, value] ] + } + } + } + + Val[makeleft] + { + out <- [[[[[[Build[List()] + ]Buffer << [[Array[]]Append[value]] + ]Left << [list] + ]Right << [List[]] + ]Offset << [index] + ]Right Offset <<[[index]+[8i32]] + ]Length << [ [[list]Length]+[1] ] + } +} + +Blueprint List +{ + Buffer + Left + Right + Offset(Int32,Naked) + Right Offset(Int32,Naked) + Length(Int32,Naked) +} + +List[:out(List)] +{ + out <- [Build[List Leaf()]]Buffer <<[Array[]] +} + +Index@List[list,index:out,not found] +{ + If[[index]<[[list]Offset >>]] + { + out, not found <- [[list]Left >>]Index[index] + }{ + If[[index] < [[list]Right Offset >>]] + { + out, not found <- [[list]Buffer >>]Index[[index]-[[list]Offset >>]] + }{ + out, not found <- [[list]Right >>]Index[[index]-[[list]Right Offset >>]] + } + } +} + +Set@List[list,index,val:out,not found] +{ + +} + + +