Godtone (talk | contribs)
m →My Python 3 code: correction 3 and addition
Godtone (talk | contribs)
m →My Python 3 code: corrections
Line 512: Line 512:
def iv(n, d, p=None): # provides automatic reduction to simplest form
def iv(n, d, p=None): # provides automatic reduction to simplest form
return unfact(fact( (n,d),p ),p)
return unfact(fact( (n,d),p ),p)
def striv(n, d=None):
def striv(n, d=None): # accepted formats: [(n, d, s)], [(n, d), s], [n, d], [n=h]
if d==None and type(n)==tuple and type(n[0])==int and type(n[1])==int:
if d==None and type(n)==tuple and type(n[0])==int and type(n[1])==int:
if len(d)==2:
if len(n)==2:
return str(n[0])+'/'+str(n[1])
return str(n[0])+'/'+str(n[1])
elif len(d)==3 and type(n[2])==int: # (possible future expansion)
elif len(n)==3 and type(n[2])==int: # (future expansion)
return str(n[0])+'/'+str(n[1])+': '+str(n[2])
return str(n[0])+'/'+str(n[1])+': '+str(n[2])
if type(d)==int and type(n)==tuple and type(n[0])==int and type(n[1])==int:
if type(d)==int and type(n)==tuple and type(n[0])==int and type(n[1])==int:
return str(n[0])+'/'+str(n[1])+': '+str(d)
return str(n[0])+'/'+str(n[1])+': '+str(d) # (future expansion)
if type(n)==int:
if type(n)==int:
if d==None:
if d==None: