From 00fb011561d7297cdbc4e21981985a56befab264 Mon Sep 17 00:00:00 2001 From: Ruben Westerberg Date: Sun, 29 Sep 2019 14:38:20 +1000 Subject: Added ch-2.p6 and readme --- challenge-027/ruben-westerberg/README | 15 +++++++-------- challenge-027/ruben-westerberg/perl6/ch-2.p6 | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 8 deletions(-) create mode 100755 challenge-027/ruben-westerberg/perl6/ch-2.p6 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)} + ); +} + -- cgit