n | def apply(f, x): | n | def foo(s, f): |
| if callable(f): | | if callable(f): |
n | return f(x) | n | return f(s) |
| | | else: |
| return f | | return f |
| | | |
| | | |
| def ADD(f, g): | | def ADD(f, g): |
n | return lambda x: apply(f, x) + apply(g, x) | n | return lambda s: foo(s, f) + foo(s, g) |
| | | |
| | | |
| def SUB(f, g): | | def SUB(f, g): |
n | return lambda x: apply(f, x) - apply(g, x) | n | return lambda s: foo(s, f) - foo(s, g) |
| | | |
| | | |
| def MUL(f, g): | | def MUL(f, g): |
n | return lambda x: apply(f, x) * apply(g, x) | n | return lambda s: foo(s, f) * foo(s, g) |
| | | |
| | | |
| def DIV(f, g): | | def DIV(f, g): |
t | return lambda x: apply(f, x) / apply(g, x) | t | return lambda s: foo(s, f) / foo(s, g) |
| | | |