Ah, thanks for that and of course! I was so focused on getting this x operation to work that I completely lost attention to other useful constructs. I really like the one with 'for'. I avoid using map where I can (personal preference)

The x operator is too bad though. The repeat operator x does repeat the array reference because as you said: The repeated expression is only evaluated once. But (0) in (0) x ... is also evaluated once, but still we get a copy of 0 for each assignment and we can get a reference to 0 for every assignment if we want too. So why can't the language detect when it is dealing with an array instead of an array reference and return a copy of eachthe 'evaluated' array expression for us too...

The last thing that I'd like to find now is something that automatically generates [0, 0] or [0, 0, 0 ...]. It would be easy to forget to change the size of the initialization list in code after changing the size of the arrays in the hash.


In reply to Re^2: Best way to initialize hash x repetition array? by Veltro
in thread Best way to initialize hash x repetition array? by Veltro

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.