Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: understand and prevent 'Out of memory!' during sub recursion

by Anonymous Monk
on Nov 09, 2017 at 15:16 UTC ( #1203043=note: print w/replies, xml ) Need Help??


in reply to understand and prevent 'Out of memory!' during sub recursion

This is why I almost never use "terse" code like this like map. You can't instantly tell what the code is doing, and you really don't have any way to break-out. (That's not what map is intended for.) The snake eats its own tail until it grows too fat and dies. Whereas, a very short subroutine would accomplish the same task and do so with clarity. There would be no meaningful difference in execution time. Terseness is really not your friend at all. Clarity, and maintainability, is.
  • Comment on Re: understand and prevent 'Out of memory!' during sub recursion

Replies are listed 'Best First'.
Re^2: understand and prevent 'Out of memory!' during sub recursion
by Eily (Prior) on Nov 09, 2017 at 16:28 UTC

    Well here Discipulus is trying to learn, so I think it's a legimate case for trying new and unusual ways. Also, "I wouldn't have done it like that" isn't very helpful when someone is asking for help correcting and understanding their mistakes.

Re^2: understand and prevent 'Out of memory!' during sub recursion
by hippo (Canon) on Nov 09, 2017 at 16:46 UTC
    You can't instantly tell what the code is doing ... a very short subroutine would accomplish the same task

    Except that Discipulus is already using a very short subroutine. So you are right in that you can't tell what the code is doing because you didn't spot that. map is perfectly fine - perhaps even ideal - in this context.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2018-08-15 22:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:









    Results (165 votes). Check out past polls.

    Notices?