n | from math import* | n | |
| | | |
| | | |
| def ADD(f, g): | | def ADD(f, g): |
| if callable(f) and callable(g): | | if callable(f) and callable(g): |
n | def h(x): | n | def NEWADD(x): |
| return f(x) + g(x) | | return f(x) + g(x) |
n | return h | n | return NEWADD |
| | | |
| if callable(f): | | elif callable(f): |
| def h(x): | | def NEWADD(x): |
| return f(x) + g | | return f(x) + g |
n | return h | n | return NEWADD |
| | | |
| if callable(g): | | elif callable(g): |
| def h(x): | | def NEWADD(x): |
| return f + g(x) | | return f + g(x) |
n | return h | n | return NEWADD |
| | | else: |
| def h(x): | | def NEWADD(x): |
| return f + g | | return f + g |
| return h | | return NEWADD |
| | | |
| | | |
| def SUB(f, g): | | def SUB(f, g): |
| if callable(f) and callable(g): | | if callable(f) and callable(g): |
n | def h(x): | n | def NEWSUB(x): |
| return f(x) - g(x) | | return f(x) - g(x) |
n | return h | n | return NEWSUB |
| | | |
| if callable(f): | | elif callable(f): |
| def h(x): | | def NEWSUB(x): |
| return f(x) - g | | return f(x) - g |
n | return h | n | return NEWSUB |
| | | |
| if callable(g): | | elif callable(g): |
| def h(x): | | def NEWSUB(x): |
| return f - g(x) | | return f - g(x) |
n | return h | n | return NEWSUB |
| | | else: |
| def h(x): | | def NEWSUB(x): |
| return f - g | | return f - g |
| return h | | return NEWSUB |
| | | |
| | | |
| def MUL(f, g): | | def MUL(f, g): |
| if callable(f) and callable(g): | | if callable(f) and callable(g): |
n | def h(x): | n | def NEWMUL(x): |
| return f(x) * g(x) | | return f(x) * g(x) |
n | return h | n | return NEWMUL |
| | | |
| if callable(f): | | elif callable(f): |
| def h(x): | | def NEWMUL(x): |
| return f(x) * g | | return f(x) * g |
n | return h | n | return NEWMUL |
| | | |
| if callable(g): | | elif callable(g): |
| def h(x): | | def NEWMUL(x): |
| return f * g(x) | | return f * g(x) |
n | return h | n | return NEWMUL |
| | | else: |
| def h(x): | | def NEWMUL(x): |
| return f * g | | return f * g |
| return h | | return NEWMUL |
| | | |
| | | |
| def DIV(f, g): | | def DIV(f, g): |
| if callable(f) and callable(g): | | if callable(f) and callable(g): |
n | def h(x): | n | def NEWDIV(x): |
| return f(x) / g(x) | | return f(x) / g(x) |
n | return h | n | return NEWDIV |
| | | elif callable(f): |
| | | def NEWDIV(x): |
| | | return f(x) / g |
| | | return NEWDIV |
| | | elif callable(g): |
| | | def NEWDIV(x): |
| | | return f / g(x) |
| | | return NEWDIV |
| | | else: |
| | | def NEWMUL(x): |
| | | return f / g |
| | | return NEWMUL |
| | | |
t | if callable(f): | t | |
| def h(x): | | |
| return f(x) / g | | |
| return h | | |
| | | |
| if callable(g): | | |
| def h(x): | | |
| return f / g(x) | | |
| return h | | |
| | | |
| def h(x): | | |
| return f / g | | |
| return h | | |
| | | |