aboutsummaryrefslogtreecommitdiff
path: root/challenge-031
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2019-10-27 04:00:26 +0000
committerGitHub <noreply@github.com>2019-10-27 04:00:26 +0000
commit74e92c47935f03a3132eaf779b75a5fb92a7838d (patch)
tree7acb37b271d396a09b91864657fc09386bdd4716 /challenge-031
parent3868d9ad324c61b1f10d43439103e976ee99d0d2 (diff)
parentf7be3a3b9b71bdfa6235287e3417f1578bedfd0a (diff)
downloadperlweeklychallenge-club-74e92c47935f03a3132eaf779b75a5fb92a7838d.tar.gz
perlweeklychallenge-club-74e92c47935f03a3132eaf779b75a5fb92a7838d.tar.bz2
perlweeklychallenge-club-74e92c47935f03a3132eaf779b75a5fb92a7838d.zip
Merge pull request #843 from adamcrussell/challenge-031
solution for challenge 031
Diffstat (limited to 'challenge-031')
-rw-r--r--challenge-031/adam-russell/blog.txt1
-rw-r--r--challenge-031/adam-russell/cxx/.precomp/.lock0
-rw-r--r--challenge-031/adam-russell/cxx/.precomp/22B95C1B62814CF03F5AD9D8EBAA9B4D33FCAD42/A5/A5FF1C641758CC02744172A50E577BBE06C2A1C5bin0 -> 3939 bytes
-rw-r--r--challenge-031/adam-russell/cxx/.precomp/22B95C1B62814CF03F5AD9D8EBAA9B4D33FCAD42/A5/A5FF1C641758CC02744172A50E577BBE06C2A1C5.repo-id1
-rw-r--r--challenge-031/adam-russell/cxx/ch-1.cxx20
-rw-r--r--challenge-031/adam-russell/cxx/ch-2.cxx13
-rw-r--r--challenge-031/adam-russell/perl5/ch-1.pl13
-rw-r--r--challenge-031/adam-russell/perl5/ch-2.pl10
-rw-r--r--challenge-031/adam-russell/raku/ch-1.rk10
-rw-r--r--challenge-031/adam-russell/raku/ch-2.rk6
10 files changed, 74 insertions, 0 deletions
diff --git a/challenge-031/adam-russell/blog.txt b/challenge-031/adam-russell/blog.txt
new file mode 100644
index 0000000000..050c27e92c
--- /dev/null
+++ b/challenge-031/adam-russell/blog.txt
@@ -0,0 +1 @@
+https://adamcrussell.livejournal.com/10620.html
diff --git a/challenge-031/adam-russell/cxx/.precomp/.lock b/challenge-031/adam-russell/cxx/.precomp/.lock
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/challenge-031/adam-russell/cxx/.precomp/.lock
diff --git a/challenge-031/adam-russell/cxx/.precomp/22B95C1B62814CF03F5AD9D8EBAA9B4D33FCAD42/A5/A5FF1C641758CC02744172A50E577BBE06C2A1C5 b/challenge-031/adam-russell/cxx/.precomp/22B95C1B62814CF03F5AD9D8EBAA9B4D33FCAD42/A5/A5FF1C641758CC02744172A50E577BBE06C2A1C5
new file mode 100644
index 0000000000..59aed5f7fa
--- /dev/null
+++ b/challenge-031/adam-russell/cxx/.precomp/22B95C1B62814CF03F5AD9D8EBAA9B4D33FCAD42/A5/A5FF1C641758CC02744172A50E577BBE06C2A1C5
Binary files differ
diff --git a/challenge-031/adam-russell/cxx/.precomp/22B95C1B62814CF03F5AD9D8EBAA9B4D33FCAD42/A5/A5FF1C641758CC02744172A50E577BBE06C2A1C5.repo-id b/challenge-031/adam-russell/cxx/.precomp/22B95C1B62814CF03F5AD9D8EBAA9B4D33FCAD42/A5/A5FF1C641758CC02744172A50E577BBE06C2A1C5.repo-id
new file mode 100644
index 0000000000..87d82fc36a
--- /dev/null
+++ b/challenge-031/adam-russell/cxx/.precomp/22B95C1B62814CF03F5AD9D8EBAA9B4D33FCAD42/A5/A5FF1C641758CC02744172A50E577BBE06C2A1C5.repo-id
@@ -0,0 +1 @@
+032C2C605063ADB95B8D4CAE8BAF3384D9083416 \ No newline at end of file
diff --git a/challenge-031/adam-russell/cxx/ch-1.cxx b/challenge-031/adam-russell/cxx/ch-1.cxx
new file mode 100644
index 0000000000..4d72ddaadd
--- /dev/null
+++ b/challenge-031/adam-russell/cxx/ch-1.cxx
@@ -0,0 +1,20 @@
+#include <iostream>
+#include <cstdlib>
+#include <csignal>
+using namespace std;
+
+void handler(int){
+ cerr << "caught an error";
+ exit(1);
+}
+
+int main () {
+ if(SIG_ERR == signal(SIGFPE, handler)){
+ cerr << "could not setup SIGFPE handler";
+ return 1;
+ }
+ int x = 9, y = 0;
+ float z = x % y;
+ cout << z << endl;
+ return 0;
+}
diff --git a/challenge-031/adam-russell/cxx/ch-2.cxx b/challenge-031/adam-russell/cxx/ch-2.cxx
new file mode 100644
index 0000000000..a5a2382f22
--- /dev/null
+++ b/challenge-031/adam-russell/cxx/ch-2.cxx
@@ -0,0 +1,13 @@
+#include <string>
+#include <iostream>
+
+#define QUOTE(name) #name
+#define MAKE_NAME(name) QUOTE(name)
+#define VARIABLE_NAME MAKE_NAME(VARIABLE)
+
+int main(){
+ using namespace std;
+ string name = VARIABLE_NAME;
+ int VARIABLE = VALUE;
+ cout << "The value of " << name << " is " << VARIABLE << "." << endl;
+}
diff --git a/challenge-031/adam-russell/perl5/ch-1.pl b/challenge-031/adam-russell/perl5/ch-1.pl
new file mode 100644
index 0000000000..a5e87c4fa5
--- /dev/null
+++ b/challenge-031/adam-russell/perl5/ch-1.pl
@@ -0,0 +1,13 @@
+use strict;
+use warnings;
+##
+# Create a function to check divide by zero error
+# without checking if the denominator is zero.
+##
+eval { my($x, $y) = (9, 0); my $a = $x/$y; };
+if($@){
+ print "caught an error: $@";
+}
+else{
+ print "no error\n";
+}
diff --git a/challenge-031/adam-russell/perl5/ch-2.pl b/challenge-031/adam-russell/perl5/ch-2.pl
new file mode 100644
index 0000000000..830a98c99d
--- /dev/null
+++ b/challenge-031/adam-russell/perl5/ch-2.pl
@@ -0,0 +1,10 @@
+##
+# Create a script to demonstrate creating dynamic variable
+# name, assign a value to the variable and finally print
+# the variable. The variable name would be passed as command
+# line argument.
+##
+$variable_name =$ARGV[0];
+$variable = $variable_name;
+$$variable = $ARGV[1];
+print "The value of \$$variable_name is $$variable.\n";
diff --git a/challenge-031/adam-russell/raku/ch-1.rk b/challenge-031/adam-russell/raku/ch-1.rk
new file mode 100644
index 0000000000..68d4fee0ec
--- /dev/null
+++ b/challenge-031/adam-russell/raku/ch-1.rk
@@ -0,0 +1,10 @@
+try {
+ my $x = 9;
+ my $y = 0;
+ say $x / $y;
+ CATCH {
+ default {
+ say "caught an error: " ~ .^name;
+ }
+ }
+}
diff --git a/challenge-031/adam-russell/raku/ch-2.rk b/challenge-031/adam-russell/raku/ch-2.rk
new file mode 100644
index 0000000000..209797aa1c
--- /dev/null
+++ b/challenge-031/adam-russell/raku/ch-2.rk
@@ -0,0 +1,6 @@
+my $variable = "\$" ~ @*ARGS[0];
+my $value = @*ARGS[1];
+spurt "Temp.pm6", "unit module Temp; my $variable = $value; say \"The value of \\$variable is $variable.\"";
+use lib ".";
+require Temp;
+unlink "Temp.pm6";