I only realized later that the version flattened to list, which I think was an ambiguity in my spec, i.e. "to make this work like map and grep", only for hashes. The spec was imperfect, but a valuable place to start, naively, to zero in on the real question (it's often hard to ask a precise question at the beginning of a task).

In fact, this school of programming already exists, and it's called "functional programming". That it's powerful is already demonstrated in many real world applications. map is borrowed from functional programming, and is the simplest, first order example of it. So at the heart of my question was is there any other functional programming support in Perl, besides map? For example transformations that take hashes to hashes, and can be composed? Let's try hmap.

It's not that I couldn't write the code for this myself (once I figured out what the spec actually was). However, there was the sneaking feeling that this was already done, well understood, and there would be better techniques for it.

Thanks for taking the time to answer my questions. I learn a lot with each round of discourse.


In reply to Re^6: map and grep (but for hashes) by zerohero
in thread map and grep (but for hashes) by zerohero

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.