Your skill will accomplish what the force of many cannot |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
The double foreach loop is a whole lot easier to read though ;-) I don't know. Maybe for a newbie, but I don't find it so. I have no trouble reading slice syntax -- I use it a lot -- and find the way it extends from 1D to 2D and so on, very natural and readable. More importantly, I prefer the single line syntax to the multi-line because it makes it very clear that this is simply initialising the HoHs to a bunch of 1s, and nothing more. I like that I can read as "Initialise the 2D hash to 1s". There is little opportunity to misread the intent and screw it up by injecting extra stuff in the loops. It would be even nicer if I could do (something like):
My point I guess is that this initialisation (whilst possibly important), is essentially a trival part of the overall algorithm, and having it as a single line gives it a weight commensurate with that. Conversely, spreading it out over 5 lines with named iterators makes it take on a weight that makes it seem far more significant than it is in the overall scheme of things. Ie. This is but a single step in the algorithm, and having it as a single line in the source code makes that very clear. Which I like, and feel is helpful when reading the overall algorithm. Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
In reply to Re^3: I hate nested loops
by BrowserUk
|
|