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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |