|
Revision 11293, 1.0 kB
(checked in by Darren_Duncan, 3 years ago)
|
|
replaced all 'use v6;' lines with 'use v6-alpha;' in 330 files (examples/, ext/, t/, t_disabled/) ... more remain to do
|
-
Property svn:mime-type set to
text/plain; charset=UTF-8
-
Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 | # Please remember to update examples/output/vmethods/math if you change this |
|---|
| 2 | # file so its output will change. |
|---|
| 3 | # |
|---|
| 4 | |
|---|
| 5 | use v6-alpha; |
|---|
| 6 | |
|---|
| 7 | multi sub is_even (Int $value) { |
|---|
| 8 | $value % 2 == 1; |
|---|
| 9 | } |
|---|
| 10 | |
|---|
| 11 | multi sub is_odd (Int $value) { |
|---|
| 12 | $value % 2 == 0; |
|---|
| 13 | } |
|---|
| 14 | |
|---|
| 15 | multi sub is_factor_of (Int $self; Int $num) { |
|---|
| 16 | $num % $self == 0; |
|---|
| 17 | } |
|---|
| 18 | |
|---|
| 19 | multi sub is_divisible_by (Int $self; Int $num) { |
|---|
| 20 | $self % $num == 0; |
|---|
| 21 | } |
|---|
| 22 | |
|---|
| 23 | multi sub is_prime(Int $value) { |
|---|
| 24 | ?none(2..sqrt($value)).is_factor_of($value); |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | say "5 is " ~ (5.is_even ?? 'even' !! 'odd'); |
|---|
| 28 | say "8 is " ~ (8.is_odd ?? 'odd' !! 'even'); |
|---|
| 29 | say "2 is" ~ (2.is_factor_of(10) ?? ' ' !! ' not ') ~ "factor of 10"; |
|---|
| 30 | say "3 is" ~ (3.is_factor_of(10) ?? ' ' !! ' not ') ~ "factor of 10"; |
|---|
| 31 | say "10 is" ~ (10.is_divisible_by(2) ?? ' ' !! ' not ') ~ "divisible by 2"; |
|---|
| 32 | say "10 is" ~ (10.is_divisible_by(3) ?? ' ' !! ' not ') ~ "divisible by 3"; |
|---|
| 33 | say "7 is" ~ (7.is_prime ?? ' '!!' not ') ~ "a prime number"; |
|---|
| 34 | say "9 is" ~ (9.is_prime ?? ' '!!' not ') ~ "a prime number"; |
|---|