f | from math import * | f | from math import * |
| | | |
| | | |
| def ADD(f, g): | | def ADD(f, g): |
n | def foo(x): | n | def foo(i): |
| if callable(f): | | if callable(f): |
n | temp1 = f(x) | n | a = f(i) |
| else: | | else: |
n | temp1 = f | n | a = f |
| if callable(g): | | if callable(g): |
n | temp2 = g(x) | n | b = g(i) |
| else: | | else: |
n | temp2 = g | n | b = g |
| return temp1 + temp2 | | return a + b |
| return foo | | return foo |
| | | |
| | | |
| def SUB(f, g): | | def SUB(f, g): |
n | def foo(x): | n | def foo(i): |
| if callable(f): | | if callable(f): |
n | temp1 = f(x) | n | a = f(i) |
| else: | | else: |
n | temp1 = f | n | a = f |
| if callable(g): | | if callable(g): |
n | temp2 = g(x) | n | b = g(i) |
| else: | | else: |
n | temp2 = g | n | b = g |
| return temp1 - temp2 | | return a - b |
| return foo | | return foo |
| | | |
| | | |
| def MUL(f, g): | | def MUL(f, g): |
n | def foo(x): | n | def foo(i): |
| if callable(f): | | if callable(f): |
n | temp1 = f(x) | n | a = f(i) |
| else: | | else: |
n | temp1 = f | n | a = f |
| if callable(g): | | if callable(g): |
n | temp2 = g(x) | n | b = g(i) |
| else: | | else: |
n | temp2 = g | n | b = g |
| return temp1 * temp2 | | return a * b |
| return foo | | return foo |
| | | |
| | | |
| def DIV(f, g): | | def DIV(f, g): |
n | def foo(x): | n | def foo(i): |
| if callable(f): | | if callable(f): |
n | temp1 = f(x) | n | a = f(i) |
| else: | | else: |
n | temp1 = f | n | a = f |
| if callable(g): | | if callable(g): |
n | temp2 = g(x) | n | b = g(i) |
| else: | | else: |
n | temp2 = g | n | b = g |
| return temp1 / temp2 | | return a / b |
| return foo | | return foo |
| | | |
t | | t | |
| #f = SUB(sin, cos) | | |
| #print(f(12), sin(12)-cos(12)) | | |
| | | |
| #g = DIV(sin, cos) | | |
| #print(g(pi/6), tan(pi/6)) | | |
| | | |
| #h = MUL(exp, 0.1) | | |
| #print(h(2), e**2/10) | | |
| | | |
| #t = ADD(lambda s: len(s), sum) | | |
| # print(t(range(5))) | | |
| | | |