def call(self, call_args): # ls = [(arg, call_arg) for arg in self.args for call_arg in call_args] if not isinstance(call_args[0], list): return call_args[0] call_val = [v for v in self.val] for i, v in enumerate(self.args): call_val = self._replacel(call_val, v, call_args[i]) return main.eval_(call_val)
def sum_(args): if isinstance(args[0], list): return sum(m.eval_(args[0]))
def tail(args): return m.eval_(m.eval_(args[0])[1:])
def fst(args): if not isinstance(args[0], list): m.panic("argument not list") else: return m.eval_(m.eval_(args[0])[0])
def is_prime(args): for i in range(2, m.eval_(args[0])): if m.eval_(args[0]) % i == 0: return False return True
def odd(args): return m.eval_(args[0]) % 2 != 0
def even(args): return m.eval_(args[0]) % 2 == 0
def abs_(args): return abs(m.eval_(args[0]))
def sq(args): return m.eval_(args[0])**2
def sqrt_(args): return math.sqrt(m.eval_(args[0]))