Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
17
Task/Test-integerness/Raku/test-integerness.raku
Normal file
17
Task/Test-integerness/Raku/test-integerness.raku
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
multi is-int ($n) { $n.narrow ~~ Int }
|
||||
|
||||
multi is-int ($n, :$tolerance!) {
|
||||
abs($n.round - $n) <= $tolerance
|
||||
}
|
||||
|
||||
multi is-int (Complex $n, :$tolerance!) {
|
||||
is-int($n.re, :$tolerance) && abs($n.im) < $tolerance
|
||||
}
|
||||
|
||||
# Testing:
|
||||
|
||||
for 25.000000, 24.999999, 25.000100, -2.1e120, -5e-2, Inf, NaN, 5.0+0.0i, 5-5i {
|
||||
printf "%-7s %-9s %-5s %-5s\n", .^name, $_,
|
||||
is-int($_),
|
||||
is-int($_, :tolerance<0.00001>);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue