laziness, impatience, and hubris | |
PerlMonks |
Using map to create a hash/bag from an arrayby spurperl (Priest) |
on Dec 17, 2005 at 10:23 UTC ( [id://517458]=perlquestion: print w/replies, xml ) | Need Help?? |
spurperl has asked for the wisdom of the Perl Monks concerning the following question:
Dear monks,
A few minutes ago I needed to "fold" an array into a hash representing a bag/set. That is, from [a, b, c] I wanted to create {a => 1, b => 1, c => 1}. Without thinking much, I slapped:
And now I wonder on the merits of this technique. I recall seeing it discussed in the monastery before, I can't don't know what to look for in the Supersearch. Any fellow monks with memory better than mine ? What I want to know, basically, is whether it's a Good Way (TM), what are the alternatives, etc.
Back to
Seekers of Perl Wisdom
|
|