n | #!/usr/bin/env python2 | n | |
| # -*- coding: utf-8 -*- | | |
| from math import * | | |
| | | |
| | | |
| def SUB(a, b): | | def SUB(f, g): |
| if callable(a) and callable(b): | | if callable(f) and callable(g): |
| def h(x): | | def h(x): |
n | return a(x) - b(x) | n | return f(x)-g(x) |
| if callable(a) and not callable(b): | | if callable(f) and (not callable(g)): |
| def h(x): | | def h(x): |
n | return a(x) - b | n | return f(x)-g |
| if not callable(a) and callable(b): | | if (not callable(f)) and callable(g): |
| def h(x): | | def h(x): |
n | return a - b(x) | n | return f-g(x) |
| if not callable(a) and not callable(b): | | if (not callable(f)) and (not callable(g)): |
| def h(x): | | def h(x): |
n | return a - b | n | return f-g |
| return h | | return h |
| | | |
| | | |
n | def DIV(a, b): | n | def DIV(f, g): |
| if callable(a) and callable(b): | | if callable(f) and callable(g): |
| def h(x): | | def h(x): |
n | return a(x)/b(x) | n | return f(x)/g(x) |
| if callable(a) and not callable(b): | | if callable(f) and not callable(g): |
| def h(x): | | def h(x): |
n | return a(x)/b | n | return f(x)/g |
| if not callable(a) and callable(b): | | if (not callable(f)) and callable(g): |
| def h(x): | | def h(x): |
n | return a/b(x) | n | return f/g(x) |
| if not callable(a) and not callable(b): | | if (not callable(f)) and (not callable(g)): |
| def h(x): | | def h(x): |
n | return a/b | n | return f/g |
| return h | | return h |
| | | |
| | | |
n | def MUL(a, b): | n | def MUL(f, g): |
| if callable(a) and callable(b): | | if callable(f) and callable(g): |
| def h(x): | | def h(x): |
n | return a(x)*b(x) | n | return f(x)*g(x) |
| if callable(a) and not callable(b): | | if callable(f) and not callable(g): |
| def h(x): | | def h(x): |
n | return a(x)*b | n | return f(x)*g |
| if not callable(a) and callable(b): | | if not callable(f) and callable(g): |
| def h(x): | | def h(x): |
n | return a*b(x) | n | return f*g(x) |
| if not callable(a) and not callable(b): | | if (not callable(f)) and (not callable(g)): |
| def h(x): | | def h(x): |
n | return a*b | n | return f*g |
| return h | | return h |
| | | |
| | | |
n | def ADD(a, b): | n | def ADD(f, g): |
| if callable(a) and callable(b): | | if callable(f) and callable(g): |
| def h(x): | | def h(x): |
n | return a(x)+b(x) | n | return f(x)+g(x) |
| if callable(a) and not callable(b): | | if callable(f) and not callable(g): |
| def h(x): | | def h(x): |
n | return a(x)+b | n | return f(x)+g |
| if not callable(a) and callable(b): | | if not callable(f) and callable(g): |
| def h(x): | | def h(x): |
n | return a+b(x) | n | return f+g(x) |
| if not callable(a) and not callable(b): | | if (not callable(f)) and (not callable(g)): |
| def h(x): | | def h(x): |
t | return a+b | t | return f+g |
| return h | | return h |
| | | |