Dear python-dev, In mathematical notation, f*g = z->f(g(z)) and f^n = f*f*f... (n times). I often run into situations in python where such operators could result in cleaner code. Eventually, I decided to implement it myself and see how it worked in practice. However, my intuitive implementation [1] doesn't seem to work. In particular, despite what it says in function's documentation, function does not seem to be in __builtin__. Furthermore, when I try to implement this through type(f) (where f is a function) I get invalid syntax errors. I hope I haven't made some trivial error; I'm rather inexperienced as a pythonist. Christopher Olah [1] Sketch: def __builtin__.function.__mul__(self, f): return lambda x: self(f(x)) def __builtin__.function.__pow__(self, n): return lambda x: reduce(lambda a,b: [f for i in range(n)]+[x])
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4