Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Try re-writing this without aliasing and it will either be much less clear syntactically; or vastly less efficient...

BrowserUk operates in an environment in which it is vital to squeeze every last, living computron from any processor, algorithm or function with which he deals, so I am not inclined to dispute his assertion that indirect access is "vastly less efficient".

I would argue with his assertion about clarity. This, of course, is very much a matter of personal taste; I'm not aware of any widely accepted metric for benchmarking 'clarity' – or even for defining its meaning! I would say that the (untested) way I have re-written  mmMxM() below is, to my taste, at least as clear as the original. (Again, all issues of performance are entirely neglected. And I don't understand what this thing is doing in the first place... some kind of matrix multiply?)

use constant N => 3; sub mmMxM { my ($ar_A, # ref. to array of ... $ar_B, # ref. to array of ... ) = @_; my @c = map [ map 0, 0..N ], 0..N; # AoA of zeros for my $i (0..N) { for my $j (0..N) { $c[$i][$j] += $ar_A->[$i][$_] * $ar_B->[$_][$j] for 0..N; } } return \@c; }

I have, believe me, the utmost respect for BrowserUk, a most subtle and puissant (that's puissant, not pissant!) monk whose programming boots I am not fit to lick clean, but I felt compelled to offer my USD0.02 on the subject of clarity.


In reply to Re^3: aliasing arrays using typeglob under strict by AnomalousMonk
in thread aliasing arrays using typeglob under strict by RockyMtn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2024-04-25 15:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found