aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2019-10-13 10:16:06 +0100
committerGitHub <noreply@github.com>2019-10-13 10:16:06 +0100
commite77dfe4dc7616e640c6d1384219adca3e140f35e (patch)
tree215a9b61d1567e03df1b183bb0b59b33544a52f4
parent43b52dd3a702d130c7e058cc64a653f0896c39b1 (diff)
parent391cdbc32dda7fc76b2bcc3d88b6d2cf073be254 (diff)
downloadperlweeklychallenge-club-e77dfe4dc7616e640c6d1384219adca3e140f35e.tar.gz
perlweeklychallenge-club-e77dfe4dc7616e640c6d1384219adca3e140f35e.tar.bz2
perlweeklychallenge-club-e77dfe4dc7616e640c6d1384219adca3e140f35e.zip
Merge pull request #750 from jmaslak/joelle-29-2-1
Joelle's solutions for 29.2 in Perl 5 & Perl 6
-rwxr-xr-xchallenge-029/joelle-maslak/perl5/ch-2.pl21
-rwxr-xr-xchallenge-029/joelle-maslak/perl6/ch-2.p615
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') { * }
+