Mercurial > repos > rhope
view countstring.rhope @ 75:0083b2f7b3c7
Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 06 Jul 2010 07:52:59 -0400 |
parents | 73e978d590c7 |
children | 0a4682be2db2 |
line wrap: on
line source
Blueprint Count String { Text Line Column } Count String[text:out] { out <- Count String At Pos[text, 0, 0] } Count String At Pos[text,line,col:out] { out <- [[[Build["Count String"]]Text <<[text]]Line <<[line]]Column <<[col] } Slice@Count String[string,index:left,right] { If[[index] = [0]] { left <- [string]Text <<[""] right <- Val[string] }{ ltext,rtext <- [[string]Text >>]Slice[index] left <- [string]Text <<[ltext] parts <- [ltext]Split["\n"] last line <- [[parts]Length] - [1] rline <- [[string]Line >>] + [last line] prercol <- [[parts]Index[last line]]Length If[[last line] > [0]] { rcol <- Val[prercol] }{ rcol <- [prercol] + [[string]Column >>] } right <- Count String At Pos[rtext, rline, rcol] } } Length@Count String[string:out] { out <- Length[[string]Text >>] } Append@Count String[left,right:out] { If[[[left]Length] > [0]] { out <- [left]Text << [ [To String[left]]Append[To String[right]] ] }{ out <- right } } =@Count String[left,right:out] { out <- [To String[left]] = [To String[right]] } Get DString@Count String[string, delims:after,before,delim,nomatch] { ,,delim,nomatch <- [[string]Text >>]Get DString[delims] { If[[dlines] > [0]] { cols <- Val[dcols] }{ If[[blines] > [0]] { cols <- [bcols] + [dcols] }{ cols <- [[bcols] + [dcols]] + [[string]Column >>] } } after <- Count String At Pos[~, [[blines]+[dlines]] + [[string]Line >>], cols] }{ before <- [string]Text <<[~] bparts <- [~]Split["\n"] preblines <- [[bparts]Length] - [1] If[[preblines] > [-1]] { blines <- Val[preblines] bcols <- Length[[bparts]Index[blines]] }{ bcols <- 0 blines <- 0 } }{ dparts <- [~]Split["\n"] dlines <- [[dparts]Length] - [1] dcols <- Length[[dparts]Index[dlines]] } } To String@Count String[string:out] { out <- [string]Text >> } Empty@Count String[string:out] { out <- Count String[""] }