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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Can you comment on this by which logic the first for conditions are set ( 0 .. $#lt -1 ) also the combination $# I have not encountered something like this what does it mean?

Absolutely. That's what this place is all about.

[ [1], [2, 3], [4, 5, 6], [7, 8, 9, 10] ]
### $#array is the highest index in @array. my $yMax = $#lt; ## $#{ ... } is the highest index in the array referenced by ... ## $array[ -1 ] is the last element in the @array ## So the following sets $xMax to highest index of the array (referenc +e) ## in the last element of @lt. Ie. The longest subarray. my $xMax = $#{ $lt[-1] }; ## Iterate through each the subarrays except the last which does need +padding for my $y ( 0 .. $yMax -1 ) { ## for $lt[ $y=0 ] ([1]), we need to add elements $y+1..$xMax ( +1..3) ## for $lt[ $y=1 ] ([2,3]), we need to add elements $y+1..$yMax ( +2..3) ## And the value we add at $lt[ $y ][ $x ] comes from $lt[ $x ][ $ +y ]. for my $x ( $y+1 .. $xMax ) push @{ $lt[ $y ] }, $lt[ $x ][ $y ]; } }

BTW: please use <code></code> tags when posting code snippets. That way they are readable :)


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^5: Convert matrix formats by BrowserUk
in thread Convert matrix formats by naturalsciences

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 lurking in the Monastery: (2)
As of 2024-04-26 00:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found