Am 30.04.2018 um 08:47 schrieb ToddAndMargo:
Hi All,
I know it would only take me 25 seconds to write one,
but do we have an odd and even function build in?
Many thanks,
-T
$ perl6 -e 'my $x=3; say $x.odd;'
No such method 'odd' for invocant of type 'Int'. Did you mean 'ord'?
in block <unit> at -e line 1
$ perl6 -e 'my $x=3; say $x.even;'
No such method 'even' for invocant of type 'Int'
in block <unit> at -e line 1
On 04/30/2018 02:05 AM, Martin Barth wrote:
> Are you aware of the %% operator?
>
> $var %% 2 checks wether it is dividable by 2.
>
>
No I was not. Thank you!
I was just going to do a
sub odd( $Num ) { return $Num % 2; }
sub even( $Num ) { return not $Num.odd; }
-T
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Computers are like air conditioners.
They malfunction when you open windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~