That's mostly how I've been operating, but I don't like always breaking things down into lists. It's good for algorithms, but you tend to lose structure.
The hmap and hgrep methods seem like a nice way to do that, because when I'm putting things together, it seems like they want to go into a big anonymous structure (multi-level hash). Think of assembling JSON like things for example. In these cases I find it more natural to work with hashes, and hashes of hashes and so forth.
By the answers it seems like the shortest thing is a few lines, which is not overly long, but lacks the super terseness of map or grep. So I think that means I need to write a little function. This isn't so hard, but it does seem that map and grep are so versatile, I was wondering if there were aspects of them I was "not getting", and therefore if there were some ultra-compact expression. It seems like 3 lines is about as short as you can go.
Thanks, RogerIn reply to Re^4: map and grep (but for hashes)
by zerohero
in thread map and grep (but for hashes)
by zerohero
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |