Dang, you're right. It works as you'd expect without overthinking it. :-) I guess what has always (seriously, since my undergrad years studying math!) confused me is that somehow when this function is introduced <https://en.wikipedia.org/wiki/Function_composition> they say (g*f)(x) = g(f(x)). The professor starts by showing f(x), and then shows how you can apply g() to the result, and lo, you have defined g*f.
(I'm sorry, I refuse to learn how to type the symbol they actually use. :-) On Sun, May 24, 2020 at 2:17 PM Tim Peters <tim.pet...@gmail.com> wrote: > [Guido] > >> I’ve never been able to remember whether (f@g)(x) means f(g(x)) or > g(f(x)). That pretty much kills the idea for me. > > [David Mertz] > > Well, it means whichever one the designers decide it should mean. But > obviously it's a thing to remember, > > and one that could sensibly go the other way. > > > > On the other hand, when I showed an example using filter() a couple days > ago, I had to try it to remember whether > > the predicate or the iterable came first. Lots of such decisions are > pretty arbitrary. > > Best I know, f@g applies g first in every language that implements a > composition operator, and in mathematics. While that may be arbitrary, > it's easy to remember: (f@g)(x) "looks a heck of a lot more like" > f(g(x)) than g(f(x)) because the former leaves the identifiers in the > same order. > -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/IH4FDKQEBPFGOW7VKDPVLUTJQBTNPMOO/ Code of Conduct: http://python.org/psf/codeofconduct/