ArithFunct/s60170124 | ArithFunct/alina13 | ||||
---|---|---|---|---|---|
f | 1 | def ADD(f, g): | f | 1 | def ADD(f, g): |
n | 2 | def add(x): | n | 2 | def fg(x): |
3 | if callable(f): | 3 | if callable(f): | ||
4 | if callable(g): | 4 | if callable(g): | ||
5 | return f(x) + g(x) | 5 | return f(x) + g(x) | ||
6 | else: | 6 | else: | ||
7 | return f(x) + g | 7 | return f(x) + g | ||
n | n | 8 | elif callable(g): | ||
9 | return f + g(x) | ||||
8 | else: | 10 | else: | ||
n | 9 | if callable(g): | n | ||
10 | return f + g(x) | ||||
11 | else: | ||||
12 | return f + g | 11 | return f + g | ||
13 | return add | 12 | return fg | ||
14 | 13 | ||||
15 | 14 | ||||
16 | def SUB(f, g): | 15 | def SUB(f, g): | ||
n | 17 | def sub(x): | n | 16 | def fg(x): |
18 | if callable(f): | 17 | if callable(f): | ||
19 | if callable(g): | 18 | if callable(g): | ||
20 | return f(x) - g(x) | 19 | return f(x) - g(x) | ||
21 | else: | 20 | else: | ||
22 | return f(x) - g | 21 | return f(x) - g | ||
n | n | 22 | elif callable(g): | ||
23 | return f - g(x) | ||||
23 | else: | 24 | else: | ||
n | 24 | if callable(g): | n | ||
25 | return f - g(x) | ||||
26 | else: | ||||
27 | return f - g | 25 | return f - g | ||
28 | return sub | 26 | return fg | ||
29 | 27 | ||||
30 | 28 | ||||
31 | def MUL(f, g): | 29 | def MUL(f, g): | ||
n | 32 | def mul(x): | n | 30 | def fg(x): |
33 | if callable(f): | 31 | if callable(f): | ||
34 | if callable(g): | 32 | if callable(g): | ||
35 | return f(x) * g(x) | 33 | return f(x) * g(x) | ||
36 | else: | 34 | else: | ||
37 | return f(x) * g | 35 | return f(x) * g | ||
n | n | 36 | elif callable(g): | ||
37 | return f * g(x) | ||||
38 | else: | 38 | else: | ||
n | 39 | if callable(g): | n | ||
40 | return f * g(x) | ||||
41 | else: | ||||
42 | return f * g | 39 | return f * g | ||
43 | return mul | 40 | return fg | ||
44 | 41 | ||||
45 | 42 | ||||
46 | def DIV(f, g): | 43 | def DIV(f, g): | ||
n | 47 | def div(x): | n | 44 | def fg(x): |
48 | if callable(f): | 45 | if callable(f): | ||
49 | if callable(g): | 46 | if callable(g): | ||
50 | return f(x) / g(x) | 47 | return f(x) / g(x) | ||
51 | else: | 48 | else: | ||
52 | return f(x) / g | 49 | return f(x) / g | ||
n | n | 50 | elif callable(g): | ||
51 | return f / g(x) | ||||
53 | else: | 52 | else: | ||
n | 54 | if callable(g): | n | ||
55 | return f / g(x) | ||||
56 | else: | ||||
57 | return f / g | 53 | return f / g | ||
58 | return div | 54 | return fg | ||
59 | 55 | ||||
t | t | 56 | |||
57 | """ | ||||
58 | from math import * | ||||
59 | |||||
60 | f = SUB(sin, cos) | ||||
61 | print(f(12), sin(12)-cos(12)) | ||||
62 | |||||
63 | g = DIV(sin, cos) | ||||
64 | print(g(pi/6), tan(pi/6)) | ||||
65 | |||||
66 | h = MUL(exp, 0.1) | ||||
67 | print(h(2), e**2/10) | ||||
68 | |||||
69 | t = ADD(len, sum) | ||||
70 | print(t(range(5))) | ||||
71 | """ | ||||
72 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|