# HG changeset patch # User Mike Pavone # Date 1293137299 18000 # Node ID 37b999dbd12e3f376b3ac4673420a9030f7aa162 # Parent ed70399a07aaa7a5a7cadd6e4162cdcf226c8058 Small change to make String Cat trees a little more balanced diff -r ed70399a07aa -r 37b999dbd12e string.rhope --- a/string.rhope Thu Dec 23 02:00:27 2010 +0000 +++ b/string.rhope Thu Dec 23 15:48:19 2010 -0500 @@ -828,26 +828,50 @@ } } +Depth@String[string:out] +{ + out <- 0 +} + +Depth@String Slice[string:out] +{ + out <- 0 +} + +Depth@String Cat[string:out] +{ + out <- Depth >>[string] +} + Blueprint String Cat { Left Right Length ByteLen + Depth } String Cat[left,right:out] { - out <- [[[[Build[String Cat()] + out <- [[[[[Build[String Cat()] ]Left <<[left] ]Right <<[right] ]Length <<[ [[left]Length]+[[right]Length] ] ]ByteLen <<[ [[left]Byte Length]+[[right]Byte Length] ] + ]Depth <<[ [1]+[Min[[left]Depth, [right]Depth]] ] } Append@String Cat[left,right:out] { - out <- String Cat[left,right] + ll <- [left]Left >> + lr <- [left]Right >> + If[[[ll]Depth] > [[lr]Depth]] + { + out <- String Cat[ll, String Cat[lr,right]] + }{ + out <- String Cat[left,right] + } } Byte@String Cat[string,index:out,invalid]