>
> having to function f and g, I want a function h so that h(x) = f(g(x))
>
I don't think there's anything quite like this in MochiKit.

What are some use cases for this? What is construct typically named?

quoting a Haskell tutorial:
"""
The (.) function (called the function composition function), takes two functions functioncomposition
andmakesthemintoone. Forinstance,ifwewrite(square . f),thismeansthat
it creates a new function that takes an argument, applies f to that argument and then
applies square to the result. Conversely, (f . square) means that it creates
a new function that takes an argument, applies square to that argument and then
appliesftothe result.
"""
 
so I think it is typically called "function composition function".

Use case:

I wanted to extract the y-koordinates of all TR elements of a specific class:
map(itemgetter("y"),
imap(getElementPosition,
        getElementsByTagAndClassName("TR","ef",parent="content")
       )
)

instead of
map(composition(itemgetter("y"),getElementPosition),
        getElementsByTagAndClassName("TR","ef",parent="content")
       )
)

Why would composition matter? Because only one mapping would need to be executed (and paranthesizes would be saved)

Harald

- on different matters: Bob, did you ever dream of visiting CERN? The place where the antimatter for exploding Vatican is created? To eat in cantinas with the worlds highest propability to stand in queue with future or past Nobel Prize Winners? To talk about Web 2.5 at the place where Web 0.1 up to Web 1.0 were developed?





--
GHUM Harald Massa
persuadere et programmare
Harald Armin Massa
Reinsburgstraße 202b
70197 Stuttgart
0173/9409607
-
PostgreSQL - supported by a community that does not put you on hold
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---

Reply via email to