diff options
| author | Joelle Maslak <jmaslak@antelope.net> | 2019-10-12 20:28:37 -0600 |
|---|---|---|
| committer | Joelle Maslak <jmaslak@antelope.net> | 2019-10-12 20:28:37 -0600 |
| commit | 391cdbc32dda7fc76b2bcc3d88b6d2cf073be254 (patch) | |
| tree | 215a9b61d1567e03df1b183bb0b59b33544a52f4 | |
| parent | 43b52dd3a702d130c7e058cc64a653f0896c39b1 (diff) | |
| download | perlweeklychallenge-club-391cdbc32dda7fc76b2bcc3d88b6d2cf073be254.tar.gz perlweeklychallenge-club-391cdbc32dda7fc76b2bcc3d88b6d2cf073be254.tar.bz2 perlweeklychallenge-club-391cdbc32dda7fc76b2bcc3d88b6d2cf073be254.zip | |
Joelle's solutions for 29.2 in Perl 5 & Perl 6
| -rwxr-xr-x | challenge-029/joelle-maslak/perl5/ch-2.pl | 21 | ||||
| -rwxr-xr-x | challenge-029/joelle-maslak/perl6/ch-2.p6 | 15 |
2 files changed, 36 insertions, 0 deletions
diff --git a/challenge-029/joelle-maslak/perl5/ch-2.pl b/challenge-029/joelle-maslak/perl5/ch-2.pl new file mode 100755 index 0000000000..a568fa97cf --- /dev/null +++ b/challenge-029/joelle-maslak/perl5/ch-2.pl @@ -0,0 +1,21 @@ +#!/usr/bin/env perl +use v5.22; +use strict; +use warnings; + +use Inline 'C'; + +MAIN: { + say "15! = " . factorial(15); +} + +__END__ +__C__ + +long factorial(long x) { + if (x < 0) { return -1; } + if (x < 1) { return 1; } + + return x * factorial(x-1); +} + diff --git a/challenge-029/joelle-maslak/perl6/ch-2.p6 b/challenge-029/joelle-maslak/perl6/ch-2.p6 new file mode 100755 index 0000000000..c5b7dd2864 --- /dev/null +++ b/challenge-029/joelle-maslak/perl6/ch-2.p6 @@ -0,0 +1,15 @@ +#!/usr/bin/env perl6 +use v6; + +use NativeCall; + +sub MAIN(UInt:D $seconds = 2) { + my $ret = native-sleep($seconds); + say "Sleep returned a value of $ret"; +} + +# This will fail on 32 bit environments, you can't use "uint" for types +# unfortunately. But if someone knows a workaround so you don't have to +# specify length (just use native C lengths), I'd love to hear that. +my sub native-sleep(uint64 -->uint64) is native is symbol('sleep') { * } + |
