Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Naive implementation of Str.tc and tc(Str)
Waiting for RaNIW to implement nqp::tc as an exercise
  • Loading branch information
lizmat committed Aug 26, 2013
1 parent efc4efd commit fe289bf
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/Str.pm
Expand Up @@ -991,6 +991,10 @@ my class Str does Stringy { # declared in BOOTSTRAP
nqp::p6box_i(nqp::chars(nqp::unbox_s(self)))
}

method tc(Str:D:) returns Str:D {
my $u := nqp::unbox_s(self);
nqp::p6box_s(nqp::tclc(nqp::substr($u,0,1)) ~ nqp::substr($u,1));
}
method tclc(Str:D:) returns Str:D {
nqp::p6box_s(nqp::tclc(nqp::unbox_s(self)))
}
Expand Down Expand Up @@ -1153,6 +1157,10 @@ sub substr-rw($s is rw, $from = 0, $chars = $s.chars - $from) {
);
}

multi sub tc(Str:D $s) returns Str:D {
my $u := nqp::unbox_s($s);
nqp::p6box_s(nqp::tclc(nqp::substr($u,0,1)) ~ nqp::substr($u,1));
}
multi sub tclc(Str:D $s) returns Str:D {
nqp::p6box_s(nqp::tclc(nqp::unbox_s($s)));
}

0 comments on commit fe289bf

Please sign in to comment.