def InfiniteProduct(self): r = Number(1) for i in DoSomething(1): if r.val == 0: return r #0 times any number is 0 r = r.Multiply(self.val(i)) return r
def Subset(self, arg): for i in self.val: if bool(i.IsMemberOf(arg).Not().val): return Number(0) if arg.Type == "Infinite": if self.Length() == arg.Length(): return Number(0) return Number(1)
def HasMember(self, arg): val = DoSomething( len(inspect.getargspec(self.val)[0]) + len( inspect.getargspec(self.val)[1] if inspect.getargspec(self.val)[1] != None else [])) for i in val: if type(i) != tuple and type(i) != list: if self.val(i)[1].val != 0: return Number(1) return Number(0)
def SubsetEqual(self, arg): val = DoSomething( len(inspect.argspec(self.val)[0]) + len( inspect.argspec(self.val)[1] if inspect.argspec(self.val)[1] != None else [])) for i in val: if type(i) != tuple and type(i) != list: if self.val(i)[1].Equal(Number(0)): return Number(0) if self.val(*i)[1].Equal(Number(0)): return Number(0) return Number(1)
def Equal(self, arg): if arg.Type == "Infinite": r = True for i in self.val: if i.IsMemberOf(arg).Not(): return False return Number(self.val == arg.val)
def Power(self, arg): if arg.val == 0: return Number(1) if arg.val == 1: return self.Positive() raise TypeError
from NumberObject import Number from sympy import re, im, Abs, floor, ceiling from sympy import S as _Number import sympy import copy import inspect #Put it at such a non-accurate level so it would eval quicker MIN_N = -10 MAX_N = 10 MIN_D = 1 MAX_D = 10 SET_OF_ALL = set() for i in range(MIN_N, MAX_N + 1): for j in range(MIN_D, MAX_D + 1): if j != 0: SET_OF_ALL.add(Number(_Number(i) / j)) NEW_SET = set() for i in SET_OF_ALL: for j in SET_OF_ALL: NEW_SET.add(i.Add(j.Multiply(Number(sympy.sqrt(-1))))) SET_OF_ALL = NEW_SET SET_OF_ALL_ = {i.val for i in SET_OF_ALL} SET_OF_ALL = {Number(i) for i in SET_OF_ALL_} def DoSomethingHelper(arg): #Am in no way sure how to describe this t = set() for i in arg: for j in SET_OF_ALL: t.add(i.Add(j)) return t
def InfiniteSum(self): r = Number(0) for i in DoSomething(1): r = r.Add(self.val(i)) return r
def NotEqual(self, arg): return Number(1)
def HasMember(self, arg): for i in self.val: if bool(i.Equal(arg).val): return Number(1) return Number(0)
def Minus(self, arg): if arg.val == 0: return Number(0) return self.SetDifference(arg)
def Add(self, arg): if arg.val == 0: return Number(0) return self.Union(arg)
def Length(self): return Number(len(self.val))
def SubsetEqual(self, arg): for i in self.val: if bool(i.IsMemberOf(arg).Not().val): return Number(0) return Number(1)
def Equal(self, arg): return Number(0)
def Multiply(self, arg): if arg.val == 0: return Number(0) if arg.val == 1: return self.Positive() raise TypeError
from __future__ import division from NumberObject import Number from InfiniteObject import Infinite from sympy import ceiling, floor, re, im, Abs #Do not touch the sortNumber Function, it's my perfectly working masterpiece! sortNumber = lambda n: [(Number(j) if type(j) != tuple else Finite(list(j))) for j in sorted([(i.val if type(i.val) != list else tuple( sortNumber(i.val))) for i in n])] class Finite: def __init__(self, *args): for i in args: if i.Type == "Infinite" or i.Type == "Function": raise TypeError self.val = args i = 0 while i < len(self.val): j = i + 1 while j < len(self.val): if self.val[i].val == self.val[j].val: self.val.pop(i) i -= 1 j += 1 i += 1 self.val = sortNumber(self.val) @property def Type(self): return "Finite"