Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^4: More functional programming utilities

by ivancho (Hermit)
on Jun 09, 2005 at 02:24 UTC ( [id://464936]=note: print w/replies, xml ) Need Help??


in reply to Re^3: More functional programming utilities
in thread More functional programming utilities

This is nice, ++ to follow

first, a suggestion - why don't you put [] around your end result map, so we can easily chain multimaps.
there's actually a lot to be said on the topic - for example, 'multimap' may not be the best name for that function.. while 'map' is List -> List ( with proviso on iterators here ), and 'reduce' is List -> Scalar, this new thing is List x List -> List.. It agrees with 'map' on the end List, but it actually provides the dimensionality reduction of 'reduce'..

now, of course, why stop here - one can imagine some sort of morphing operator multireduce(n,m) ListOfBlocks, AoAoA..A that colapses N-dim structures to M-dim ones..

but this goes into academic grounds - I can't imagine this being useful, or easily mastered thing..

lastly, what is Data::Dumper::SLC? I can't find it anywhere.. personal extension ?
  • Comment on Re^4: More functional programming utilities

Replies are listed 'Best First'.
Re^5: More functional programming utilities
by BrowserUk (Patriarch) on Jun 09, 2005 at 03:31 UTC
    first, a suggestion - why don't you put around your end result map, so we can easily chain multimaps.

    In part because I didn't think of doing that. But now you've made me think about it, I think that I would leave it as it is. Adding it internally would make the user that wants the the list rather than a LoL have to wrap the call in @{ multimap [ ... ] } to get at it.

    As is, to get the LoL, you do [ multimap [ ...] ].

    In the former I would be creating a list only for the user to discard it. In the latter, he creates it if he needs it. Which I think is a good reason to leave it as is?

    'multimap' may not be the best name for that function..

    I just went with the OPs name, but I agree that it may not best capture the semantics. I'd favour something shorter. 'map' is well understood in Perl circles so I think that should be in there somewhere.

    • 'mmap' -- sounds like a memory thing.
    • 'mapn' -- I have one called that that passes n elements at a time from a single list
    • 'maps' -- Hmm.Not quite.
    • 'mapreduce' -- A Southern Mother's ill-feelings?
    • Shame we can't use single quotes in function names like Haskell -- map'm -- Too cute?
    • 'mapm'?
    • 'mapall'?
    • 'decons' or should that be 'discons'?
    • 'heads' -- Kinda fits, but ...?
    What is Data::Dumper::SLC?

    It's my Just_a_Dumper dumper. No attempt at making the output evallable. No attempt to fold self-referrencial structures (though it does economically detect and flag them). It streams on-the-fly (avoiding accumlating anything in memory) to STDOUT (or an option filehandle) and wraps at 80 or a specifyable limit. It writes as compact a representation as is comensurate with being readable.

    When I asked here if anyone knew of such an animal, the basic respose was that nobody except myself ever needed such a thing, so I never got around to documenting or packaging it.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.

      'multimap' may not be the best name for that function..

      I just went with the OPs name, but I agree that it may not best capture the semantics. I'd favour something shorter. 'map' is well understood in Perl circles so I think that should be in there somewhere.

      Yeah, I was at a loss as to what to name this thing. In Scheme and other Lisp dialects, it's just called map. I am aware that multimap clashes with part of the C++ STL, but then again, so does map. Maybe mapmulti is a good name.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://464936]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-24 23:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found