Mercurial > repos > tabletprog
diff modules/string.tp @ 259:32964a4e7a33
Add ltrim method to string
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 29 May 2014 18:51:15 -0700 |
parents | 5b830147c1cd |
children | d6a4c9e7716e |
line wrap: on
line diff
--- a/modules/string.tp Wed May 28 09:48:09 2014 -0700 +++ b/modules/string.tp Thu May 29 18:51:15 2014 -0700 @@ -257,6 +257,25 @@ pieces append: self } + ltrim <- { + l <- length + start <- 0 + space <- " " byte: 0 + tab <- "\t" byte: 0 + nl <- "\n" byte: 0 + cr <- "\r" byte: 0 + + while: { + if: start < l { + b <- byte: start + b = space || b = tab || b = nl || b = cr + } + } do: { + start <- start + 1 + } + from: start + } + trim <- { l <- length start <- 0