Skip to content

Commit

Permalink
Add samecase method to the Any class in the setting.
Browse files Browse the repository at this point in the history
  • Loading branch information
cspencer committed Apr 18, 2009
1 parent 341f449 commit a245b4d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/setting/Any-str.pm
Expand Up @@ -58,6 +58,21 @@ class Any is also {
$char
}

our Str multi method samecase(Str $pattern) is export {
my @pattern = $pattern.split('');
[~] gather {
my $p = "";
for (~self).split('') -> $s {
$p = @pattern.shift if @pattern;
given $p {
when /<upper>/ { take $s.uc }
when /<lower>/ { take $s.lc }
default { take $s }
}
}
}
}

our List multi method split(Code $delimiter, $limit = *) {
my $s = ~self;
my $l = $limit ~~ Whatever ?? Inf !! $limit;
Expand Down
1 change: 1 addition & 0 deletions t/spectest.data
Expand Up @@ -375,6 +375,7 @@ S32-str/p5chomp.t
S32-str/p5chop.t
S32-str/pos.t
S32-str/rindex.t
S32-str/samecase.t
S32-str/split-simple.t
S32-str/sprintf.t
S32-str/substr.t
Expand Down

0 comments on commit a245b4d

Please sign in to comment.