good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re^3: Finding sum of numbers and storing it an Arrayby tobyink (Canon) |
on Sep 21, 2020 at 11:03 UTC ( [id://11121994]=note: print w/replies, xml ) | Need Help?? |
To be clear, in some programming languages, there's a data structure called a "Map". Java is one such language. It stores a mapping from one set of data (the keys) to another set of data (the values). Perhaps domain names to IP addresses:
Perl doesn't have a native map datatype. For some purposes, Perl hashes can be used. But if the keys can't be reduced to strings, Perl hashes become trickier. (Tied hashes and fieldhashes can work around this limitation to an extent.) The Perl map keyword doesn't have anything to do with Map data structures though. It operates on lists. (And an array is basically just a way of storing a list in a variable.) Anything you do with map and grep, you can do with plain old loops, but map and grep are often clearer ways to express yourself. A way to think of it might be: can you speak/write using only one-syllable words?
In Section
Seekers of Perl Wisdom
|
|