| parrotcode: Cardinal String class and related functions | |
| Contents | Language Implementations | Cardinal |

CardinalString - Cardinal String class and related functions

This file sets up the CardinalString type.
Stolen from Rakudo

selfself.
Returns selfself in reverse order.self in reverse order.
Destructive update.self with all upper case letters converted to lower caseself with all lower case letters converted to upper case Returns a copy of C<self> with the first character converted to uppercase and the remainder to lowercase.
Return the number of characters in C<self>
subscript operator. Accepts [(-)? int], [(-)?int, (-)?int]

our Str multi Str::lc ( Str $string )
our Str multi Str::lcfirst ( Str $string )
lc, but only affects the first character. our Str multi Str::uc ( Str $string )
our Str multi Str::ucfirst ( Str $string )
our Str multi Str::capitalize ( Str $string )
lc on the entire string, then performing a s:g/(\w+)/{ucfirst $1}/ on it. our CardinalArray multi Str::split ( Str $delimiter , Str $input = $+_, Int $limit = inf )
our CardinalArray multi Str::split ( Rule $delimiter = /\s+/, Str $input = $+_, Int $limit = inf )
our CardinalArray multi Str::split ( Str $input : Str $delimiter , Int $limit = inf )
our CardinalArray multi Str::split ( Str $input : Rule $delimiter , Int $limit = inf )
split(' ') will translate to .words or some such. Null trailing fields are no longer trimmed by default. We might add some kind of :trim flag or introduce a trimlist function of some sort. multi substr (Str $s, StrPos $start : StrPos $end, $replace)
multi substr (Str $s, StrPos $start, StrLen $length : $replace)
multi substr (Str $s, StrLen $offset : StrLen $length, $replace)
our Str method Str::chop ( Str $string: )

our Char multi P5emul::Str::p5chop ( Str $string is rw )
our Char multi P5emul::Str::p5chop ( Str *@strings = ($+_) is rw )
$string, and returns it. Called with a list, it chops each item in turn, and returns the last character chopped. our Int multi P5emul::Str::p5chomp ( Str $string is rw )
our Int multi P5emul::Str::p5chomp ( Str *@strings = ($+_) is rw )
p5chop, only removes trailing chars that match /\n/. In either case, it returns the number of chars removed. our Str method Str::chomp ( Str $string: )
our CardinalArray multi Str::words ( Rule $matcher = /\S+/, Str $input = $+_, Int $limit = inf )
our CardinalArray multi Str::words ( Str $input : Rule $matcher = /\S+/, Int $limit = inf )
|
|
|