Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Split Any.ord into Any.ord and Any.ords, add Any.chrs.
  • Loading branch information
colomon committed Dec 10, 2010
1 parent fedc117 commit d1e6636
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
11 changes: 8 additions & 3 deletions src/core/Cool-num.pm
Expand Up @@ -83,6 +83,10 @@ augment class Cool {
~(pir::chr__SI(self))
}

our Str multi method chrs() {
self>>.chr.join;
}

method rand($x:) {
(+$x).rand;
}
Expand Down Expand Up @@ -324,9 +328,10 @@ multi sub postfix:<i>($z) {
(+$z)i;
}

proto chr($graph) {
$graph.chr;
}
proto sub chr($graph) { $graph.chr; }
proto sub chrs(@graphs) { @graphs.chrs; }
multi sub chrs(@graphs) { @graphs.chrs; }
multi sub chrs(*@graphs) { @graphs.chrs; }

proto sub srand($seed) {
srand(+$seed);
Expand Down
27 changes: 12 additions & 15 deletions src/core/Cool-str.pm
Expand Up @@ -407,14 +407,16 @@ augment class Cool {
}

our multi method ord() {
given self.chars {
when 0 { fail('Can not take ord of empty string'); }
when 1 { pir::box__PI(pir::ord__IS(self)); }
default {
gather for self.comb {
take pir::box__PI(pir::ord__IS($_))
}
}
if self eq "" {
fail('Can not take ord of empty string');
}

pir::box__PI(pir::ord__IS(self));
}

our multi method ords() {
gather for self.comb {
take $_.ord;
}
}

Expand Down Expand Up @@ -500,13 +502,8 @@ augment class Cool {
}
}

multi sub ord($string) {
$string.ord;
}

proto ord($string) {
$string.ord;
}
proto ord($string) { $string.ord; }
proto ords($string) { $string.ords; }

our Str proto sub infix:<x>($str, $n) {
$n > 0 ?? ~(pir::repeat__SSI($str, $n)) !! ''
Expand Down

0 comments on commit d1e6636

Please sign in to comment.