1: #line 21 "felix_func.ipk"
2: from interscript.felix.model.basecat import category
3:
4: class function:
5: def __init__(self, *args):
6: self.funcs = args
7: self.normalise()
8:
9: def __call__(self, arg):
10: for f in self.funcs:
11:
12: arg = f(arg)
13: return arg
14:
15: def __and__(self,func):
16: return apply(function,self.funcs+func.funcs).normalise()
17:
18: def __mul__(self, func):
19: return function(function_product(self,func))
20:
21: def __add__(self, func):
22: return function(function_sum(self,func))
23:
24: def normalise(self):
25: if self.funcs:
26: first = self.funcs[0]
27: if isinstance(first, constant):
28: self.funcs = (constant(self(None)),)
29: return self
30: