diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-01-12 00:30:40 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-12 00:30:40 +0000 |
| commit | e82dfed04958c41791639d841e06d2f8c6bf588e (patch) | |
| tree | fc03fcbbfe8915e5ab96d0c5bc6d6bf66e8a23b9 /challenge-095 | |
| parent | e73990e9d52f6b26764bc0f163bce9d93255d46e (diff) | |
| parent | 5b590d0f8bce7dfed83c720148bff305b23a011b (diff) | |
| download | perlweeklychallenge-club-e82dfed04958c41791639d841e06d2f8c6bf588e.tar.gz perlweeklychallenge-club-e82dfed04958c41791639d841e06d2f8c6bf588e.tar.bz2 perlweeklychallenge-club-e82dfed04958c41791639d841e06d2f8c6bf588e.zip | |
Merge pull request #3219 from ash/master
ash 095
Diffstat (limited to 'challenge-095')
| -rw-r--r-- | challenge-095/ash/raku/ch-1.raku | 8 | ||||
| -rw-r--r-- | challenge-095/ash/raku/ch-2.raku | 30 |
2 files changed, 38 insertions, 0 deletions
diff --git a/challenge-095/ash/raku/ch-1.raku b/challenge-095/ash/raku/ch-1.raku new file mode 100644 index 0000000000..af959ff4f1 --- /dev/null +++ b/challenge-095/ash/raku/ch-1.raku @@ -0,0 +1,8 @@ +#!/usr/bin/env raku +# +# Task 1 from +# https://perlweeklychallenge.org/blog/perl-weekly-challenge-095/ + +unit sub MAIN(Int $n); + +say +($n.flip eq $n); diff --git a/challenge-095/ash/raku/ch-2.raku b/challenge-095/ash/raku/ch-2.raku new file mode 100644 index 0000000000..4ad212a893 --- /dev/null +++ b/challenge-095/ash/raku/ch-2.raku @@ -0,0 +1,30 @@ +#!/usr/bin/env raku +# +# Task 2 from +# https://perlweeklychallenge.org/blog/perl-weekly-challenge-095/ + +# The taks is to demonstrate stack _operations_, not _imlementaion_. + +class Stack { + has @!stack; + + method push($n) { @!stack.push($n) } + method pop { @!stack.pop } + method top { @!stack[*-1] } + method min { @!stack.min } + + method empty { !@!stack } +} + +my $s = Stack.new; +# $s.stack; # is unreachable + +for ^10 { + my $n = 10.rand.Int; + say "push($n)"; + $s.push($n); + + say "\ttop = {$s.top}, min = {$s.min}"; +} + +say "pop() = {$s.pop}" while !$s.empty; |
