diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2019-07-28 05:10:22 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-28 05:10:22 +0100 |
| commit | 4f61c5490b237866b9ae95d4437d3a4957f8e495 (patch) | |
| tree | 69b284255cf0c63031bab7d6d8574fd6fd2b6bab | |
| parent | ecccc1fa171f749fd70b1ef60e8a63d79cf6e652 (diff) | |
| parent | e7643ac0399f5457a7b307c244f33ea4d24fa0f8 (diff) | |
| download | perlweeklychallenge-club-4f61c5490b237866b9ae95d4437d3a4957f8e495.tar.gz perlweeklychallenge-club-4f61c5490b237866b9ae95d4437d3a4957f8e495.tar.bz2 perlweeklychallenge-club-4f61c5490b237866b9ae95d4437d3a4957f8e495.zip | |
Merge pull request #432 from PerlMonk-Athanasius/branch-for-challenge-018
Fixed formatting by converting tabs to spaces
| -rw-r--r-- | challenge-018/athanasius/perl6/MyPriorityQueue.pm6 | 52 | ||||
| -rw-r--r-- | challenge-018/athanasius/perl6/ch-1.p6 | 4 | ||||
| -rw-r--r-- | challenge-018/athanasius/perl6/ch-2.p6 | 8 |
3 files changed, 32 insertions, 32 deletions
diff --git a/challenge-018/athanasius/perl6/MyPriorityQueue.pm6 b/challenge-018/athanasius/perl6/MyPriorityQueue.pm6 index 2fbe576368..abc3f80ed0 100644 --- a/challenge-018/athanasius/perl6/MyPriorityQueue.pm6 +++ b/challenge-018/athanasius/perl6/MyPriorityQueue.pm6 @@ -30,40 +30,40 @@ informations. It should serve the following operations: class MyPriorityQueue { - use Heap; + use Heap; - has Heap $!heap; + has Heap $!heap; - submethod BUILD(Bool :$reverse = False) - { - $!heap = $reverse ?? Heap[-*<order>].new - !! Heap[ *<order>].new; - } + submethod BUILD(Bool :$reverse = False) + { + $!heap = $reverse ?? Heap[-*<order>].new + !! Heap[ *<order>].new; + } - method is_empty(--> Bool) - { - return !?$!heap; - } + method is_empty(--> Bool) + { + return !?$!heap; + } - method insert_with_priority(Int:D $priority, Any:D $element) - { - $!heap.push: { order => $priority, - datum => $element, }; - } + method insert_with_priority(Int:D $priority, Any:D $element) + { + $!heap.push: { order => $priority, + datum => $element, }; + } - method pull_highest_priority_element(--> Any) - { - my Any $element; + method pull_highest_priority_element(--> Any) + { + my Any $element; - unless self.is_empty() - { - my %top = $!heap.pop; + unless self.is_empty() + { + my %top = $!heap.pop; - $element = %top< datum >; - } + $element = %top< datum >; + } - return $element; - } + return $element; + } } ################################################################################ diff --git a/challenge-018/athanasius/perl6/ch-1.p6 b/challenge-018/athanasius/perl6/ch-1.p6 index fbbfdc6c87..e8d06ba552 100644 --- a/challenge-018/athanasius/perl6/ch-1.p6 +++ b/challenge-018/athanasius/perl6/ch-1.p6 @@ -26,8 +26,8 @@ details. sub MAIN ( Str:D $string1, - Str:D $string2, - *@strings3-n + Str:D $string2, + *@strings3-n ) { my @strings = $string1, $string2; diff --git a/challenge-018/athanasius/perl6/ch-2.p6 b/challenge-018/athanasius/perl6/ch-2.p6 index 2737dc4ea6..1823c54075 100644 --- a/challenge-018/athanasius/perl6/ch-2.p6 +++ b/challenge-018/athanasius/perl6/ch-2.p6 @@ -35,7 +35,7 @@ use MyPriorityQueue; sub MAIN() { - say ''; + say ''; # (1) Larger number = higher priority @@ -53,7 +53,7 @@ sub MAIN() $pq.insert_with_priority( 1, 'dog.'); $pq.insert_with_priority( 7, 'fox'); - extract-and-display($pq); + extract-and-display($pq); # (2) Lower number = higher priority @@ -71,14 +71,14 @@ sub MAIN() $pq.insert_with_priority( 4, 'do'); $pq.insert_with_priority(-2, "There's"); - extract-and-display($pq); + extract-and-display($pq); } sub extract-and-display(MyPriorityQueue:D $pq) { my @elements; @elements.push: $pq.pull_highest_priority_element until $pq.is_empty; - + say join(' ', @elements); } |
