Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: how to get average of matrices' elements?

by Marshall (Canon)
on Dec 01, 2016 at 16:52 UTC ( [id://1177067]=note: print w/replies, xml ) Need Help??


in reply to how to get average of matrices' elements?

Re:Indenting.
I saw the post by Hippo at Re: how to get average of matrices' elements?. A few extra comments...

How many spaces to use for each indentation level is actually something that has been academically studied. The answer is "3 or 4 spaces". 2 is too few for good readability and 5 winds up taking up more space while not improving readability. 3 or 4 appear to be almost the same. Certainly 1 is too few. The human eye will just get lost.

To use tabs or not in the code is something that can start a long, very emotional discussion. I personally do not put tabs anywhere in the code or comments.

If you use an editor that is designed to be used for writing code, there will be special features that make it easy to enforce whatever style you prefer. For example, my editor has an option, "convert tabs to spaces". Without doing something special, I can't wind up with any embedded tab characters.

There is a fair amount of variability on the "braces style". One way is like you did it. For Perl code, I prefer to put the initial opening brace on its own line. Like this:

for ($a=0; $a<=2; $a++) { for ($b=0; $b<=2; $b++) { $m_avrg[$a][$b] = ($m_avrg[$a][$b] + $list[$a][$b]); print "$m_avrg[$a][$b] \n"; } }
I find that easier to read. But again, mileage varies a lot! You can make up your own mind about that.

For other languages like Java, I use the more vertically compact form because there winds up being a whole mess of little itty bitty "getters and setters". So I am flexible about this point, depending upon the situation.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-26 05:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found