On 10/03/2017 11:35 PM, Richard Hainsworth wrote:
The suggested solution to this thread seems odd to me. It confuses a
storage structure with information about the elements, and doesn't use
the power of perl6.
An associative array is useful because non-integer indexes are possible
and hashing makes storage efficient. This makes referencing data about
eg a person using the person's name. If the key to the hash is not
something that is intrinsicly useful, why use a hash. Just use another
array.
Actually, in the brain teaser exercise I presented, the keys
were not alphabetical or numerically ordered, so sort was out.
And actual use was two fold.
1) the index allowed for printing in a special order of
one's choosing
2) the power of the hash is maintained for when you want
to grab data out of it by addressing with a particular key,
the order entered not being an issue.
The idea was to increase the power of the hash.
In the original application for this, I was reading SMTP settings
in from an INI file. Then placing them into a hash. If the
INI file did not exist, I wrote a new one out with instructions
on how to use the INI file (in the INI file) and a base template
to fill in. With out the entries being in order, the template
did not match the order of the instructions and the template
looked pretty stupid and confusing.
I have since taken another route, but thought the brain teaser
was to rich in syntax examples to toss