Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Perl 6 versions of cis() and rand() to setting (RT #64108).
Patch courtesy Cory Spencer <cspencer@sprocket.org>.
- Loading branch information
Showing
2 changed files
with
26 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,45 @@ | ||
class Any is also { | ||
our Int multi method ceiling (Num $x:) is export { | ||
our Int multi method ceiling is export { | ||
return Q:PIR { | ||
$P0 = find_lex "$x" | ||
$N0 = $P0 | ||
$N0 = self | ||
$I0 = ceil $N0 | ||
%r = box $I0 | ||
} | ||
} | ||
our Int multi method floor (Num $x:) is export { | ||
our Complex multi method cis is export { | ||
unpolar(1.0, self) | ||
} | ||
our Int multi method floor is export { | ||
return Q:PIR { | ||
$P0 = find_lex "$x" | ||
$N0 = $P0 | ||
$N0 = self | ||
$I0 = floor $N0 | ||
%r = box $I0 | ||
} | ||
} | ||
|
||
our Int multi method round (Num $x:) is export { | ||
our Num method rand { | ||
return Q:PIR { | ||
$N0 = self | ||
$P0 = get_hll_global ['Any'], '$!random' | ||
$N1 = $P0 | ||
$N0 *= $N1 | ||
%r = box $N0 | ||
} | ||
} | ||
our Int multi method round is export { | ||
return Q:PIR { | ||
$P0 = find_lex "$x" | ||
$N0 = $P0 | ||
$N0 = self | ||
$N0 = $N0 + 0.5 | ||
$I0 = floor $N0 | ||
%r = box $I0 | ||
} | ||
} | ||
} | ||
|
||
our Int sub rand (*@args) { | ||
die "too many arguments passed - 0 params expected" if @args; | ||
1.rand | ||
} |