aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYsmael Ebreo <Ysmael.Ebreo@latticesemi.com>2019-09-29 00:42:30 +0800
committerYsmael Ebreo <Ysmael.Ebreo@latticesemi.com>2019-09-29 00:42:30 +0800
commit7bfac2061d9a46db4d2f8405f0f230f1641daa28 (patch)
tree7f3a313e451f508a3c7c430a3380085025ffc6f2
parent8b17faf74310bc46d67617468928ede6fa17c271 (diff)
downloadperlweeklychallenge-club-7bfac2061d9a46db4d2f8405f0f230f1641daa28.tar.gz
perlweeklychallenge-club-7bfac2061d9a46db4d2f8405f0f230f1641daa28.tar.bz2
perlweeklychallenge-club-7bfac2061d9a46db4d2f8405f0f230f1641daa28.zip
Added perl6 solution task#2
-rw-r--r--challenge-027/yet-ebreo/perl6/ch-2.p623
1 files changed, 23 insertions, 0 deletions
diff --git a/challenge-027/yet-ebreo/perl6/ch-2.p6 b/challenge-027/yet-ebreo/perl6/ch-2.p6
new file mode 100644
index 0000000000..52f254c429
--- /dev/null
+++ b/challenge-027/yet-ebreo/perl6/ch-2.p6
@@ -0,0 +1,23 @@
+# Write a script that allows you to capture/display historical data. It could be an object or a scalar. For example
+# my $x = 10; $x = 20; $x -= 5;
+# After the above operations, it should list $x historical value in order.
+
+class hist {
+ has @.history;
+ has $!var handles <Str gist FETCH Numeric>;
+ method STORE($val) {
+ push @.history, $val;
+ $!var = $val;
+ }
+}
+
+my \x = hist.new(history => []);
+
+x = 10;
+x = 20;
+x -= 5;
+x = 3.1416;
+x = Q[a quick brown fox jumps over the lazy dog];
+x = 1e3;
+x*= sqrt 3;
+.say for x.history;