aboutsummaryrefslogtreecommitdiff
path: root/challenge-027
diff options
context:
space:
mode:
authorRuben Westerberg <drclaw@mac.com>2019-09-29 14:38:20 +1000
committerRuben Westerberg <drclaw@mac.com>2019-09-29 14:38:20 +1000
commit00fb011561d7297cdbc4e21981985a56befab264 (patch)
tree64ccdb0b24634c452ff46c05fc03aac8dc9e79bc /challenge-027
parent1d50267e1aaf80b678ec31b32825d96b396a504f (diff)
downloadperlweeklychallenge-club-00fb011561d7297cdbc4e21981985a56befab264.tar.gz
perlweeklychallenge-club-00fb011561d7297cdbc4e21981985a56befab264.tar.bz2
perlweeklychallenge-club-00fb011561d7297cdbc4e21981985a56befab264.zip
Added ch-2.p6 and readme
Diffstat (limited to 'challenge-027')
-rw-r--r--challenge-027/ruben-westerberg/README15
-rwxr-xr-xchallenge-027/ruben-westerberg/perl6/ch-2.p618
2 files changed, 25 insertions, 8 deletions
diff --git a/challenge-027/ruben-westerberg/README b/challenge-027/ruben-westerberg/README
index b22be03bd3..c17b59a016 100644
--- a/challenge-027/ruben-westerberg/README
+++ b/challenge-027/ruben-westerberg/README
@@ -2,15 +2,14 @@ Solution by Ruben Westerberg
ch-1.pl and ch-1.p6
===
-Stone and Jewels
-Run the program with two arguments, the first one being the stone, and the second one the jewel.
-The total number of letters in the jewel present in the stone is printed.
-If no arguments are given a test set is used.
+Intersecting lines.
+Run the program. you will be propted to enter two points for the first line and then two points for the second line.
+Points are intered as interleved xy pairs
+example:
+ When prompted to enter the line starting at the origin and ending at x=5 and y=10, the two points are entered as follows:
+ 0 0 5 10
ch-2.pl and ch-2.p6
===
-Angular average
-Run the program with at least one argument. Each argument is an angle in degrees.
-The output is the average of the list of angles supplied.
-If no arguments are given, a test list is used.
+Run the program to demonstrate history of every assignement to a variable.
diff --git a/challenge-027/ruben-westerberg/perl6/ch-2.p6 b/challenge-027/ruben-westerberg/perl6/ch-2.p6
new file mode 100755
index 0000000000..ec2d2af03d
--- /dev/null
+++ b/challenge-027/ruben-westerberg/perl6/ch-2.p6
@@ -0,0 +1,18 @@
+#!/usr/bin/env perl6
+
+my @history;
+my $value:=remembering(@history);
+$value=4;
+$value=10;
+$value=100;
+put "Current value of variable: $value";
+put "Historical Values: " , join " ",@history;
+
+
+sub remembering (@history) {
+ return-rw Proxy.new(
+ FETCH => method () {@history[*-1]},
+ STORE => method ($new) {;@history.push($new)}
+ );
+}
+