in reply to add missing elements and remove duplicates....and some more questions.
The do_it_all() functions in the OP and here use methods for determining the biggest and smallest numbers from the argument list that I've extracted and respectively named do_it_all_1() and do_it_all_2() below.
Questions:c:\@Work\Perl\monks\pritesh_ugrankar>perl -wMstrict -le "do_it_all_1(1, 2, 3); do_it_all_2(0, 1, 2, 3); ;; ;; sub do_it_all_1 { print qq{do_it_all_1: (@_)}; ;; my $biggest = shift @_; foreach my $num (@_) { if ($num > $biggest) { $biggest = $num; } } ;; my $smallest = shift @_; foreach my $smallnum (@_) { if ($smallnum < $smallest) { $smallest = $smallnum; } } ;; print qq{smallest == $smallest, biggest == $biggest}; } ;; sub do_it_all_2 { print qq{do_it_all_2: (@_)}; ;; my $biggest = @_; foreach my $bignum (@_) { if ($bignum > $biggest) { $biggest = $bignum; } } ;; my $smallest = @_; foreach my $smallnum (@_) { if ($smallnum < $smallest) { $smallest = $smallnum; } } ;; print qq{smallest == $smallest, biggest == $biggest}; } " do_it_all_1: (1 2 3) smallest == 2, biggest == 3 do_it_all_2: (0 1 2 3) smallest == 0, biggest == 4
(The foregoing is intended as propaganda for a Test::More development approach that might have uncovered these inconsistencies earlier.)
One other small perplexity. You describe the feedback given you regarding the code of the OP as "[t]hat I did not try to address the issue, but circumvented the issue ..." But the "issue" seems to be described in the paragraph beginning "Given a random series of numbers, ...", and your code seems to address this requirement statement directly. (Others have touched on this.) Can you clarify the dissatisfaction of your instructor/TA? It doesn't make sense to me. (The whole business about Linux Mint/Ubuntu/whatever seems entirely irrelevant.)
Give a man a fish: <%-{-{-{-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: add missing elements and remove duplicates....and some more questions.
by pritesh_ugrankar (Monk) on Apr 24, 2017 at 13:31 UTC | |
by AnomalousMonk (Archbishop) on Apr 24, 2017 at 16:34 UTC | |
by pritesh_ugrankar (Monk) on Apr 24, 2017 at 20:04 UTC | |
by Marshall (Canon) on Apr 25, 2017 at 15:10 UTC | |
by pritesh_ugrankar (Monk) on Apr 25, 2017 at 18:48 UTC | |
by Anonymous Monk on Apr 24, 2017 at 14:15 UTC |