Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: Challenge: Sorting Sums Of Sorted Series

by ikegami (Pope)
on Feb 03, 2010 at 21:33 UTC ( #821273=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Challenge: Sorting Sums Of Sorted Series
in thread Challenge: Sorting Sums Of Sorted Series

Your code needs some TLC and your for (0 .. $#list) should probably be for (;;) loops.

Why? Do you believe the list gets flattened? No, for (EXPR..EXPR) is implemented as a counting loop.


Comment on Re^3: Challenge: Sorting Sums Of Sorted Series
Download Code
Re^4: Challenge: Sorting Sums Of Sorted Series
by Limbic~Region (Chancellor) on Feb 03, 2010 at 21:50 UTC
    ikegami,
    Notice I didn't say blokhead was wrong. I said should because it would make it obvious. Not everyone has a grasp of how things are implemented in all versions of perl. In fact, this is what perlop has to say on the matter.

    In list context, it returns a list of values counting (up by ones) from the left value to the right value.....In the current implementation, no temporary array is created when the range operator is used as the expression in foreach loops, but older versions of Perl might burn a lot of memory when you write something like this:

    Again, someone that doesn't follow perl closely might think - what version would blokhead's solution be breaking the rules or will this continue to be correct in the next version. Making it obvious eliminates any casual observer confusion.

    Cheers - L~R

      I'm not concerned about about the behaviour of versions of Perl before 5.6, and I think very very few are in the other camp, so I think that warning shouldn't be in the docs anymore. I find for EXPR..EXPR much clearer than the alternative, so I disagree with your opinion that he should switch to the alternative.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://821273]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (13)
As of 2014-09-18 15:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (116 votes), past polls