From a4c13834fb5093c8b3cd5eef5d65a6c99ee6b9c9 Mon Sep 17 00:00:00 2001 From: Matthew Strapp Date: Sun, 29 Sep 2019 17:34:21 -0500 Subject: Finish Lab because I stoopid --- csci1913/Python/lab3_strap012.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'csci1913/Python/lab3_strap012.py') diff --git a/csci1913/Python/lab3_strap012.py b/csci1913/Python/lab3_strap012.py index 1e121a6..bc64d2a 100644 --- a/csci1913/Python/lab3_strap012.py +++ b/csci1913/Python/lab3_strap012.py @@ -1,16 +1,9 @@ #"New" functions def Reduce(F,S): if len(S)==0: - return -999 + return -255 else: - return F(S[0],Reduce(F,S[1:])) -def filter(P,S): - if len(S)==0: - return () - elif P(S[0]): - return (S[0]) + filter(P,S[1:]) - else: - return filter(P,S[1:]) + return F(Reduce(F,S[:-1]),S[-1]) def returnGreater(a,b): if a > b: return a @@ -18,12 +11,19 @@ def returnGreater(a,b): #Implementation from Lab def Sort(T): - return None + if len(T)==0: + return () + else: + return (Sort(Remove(T,Maximum(T))))+(Maximum(T),) def Maximum(T): return Reduce(returnGreater,T) def Remove(T,E): - return None - + if len(T)==0: + return () + elif T[0] is E: + return T[1:] + else: + return (T[0],)+Remove(T[1:],E) # -- cgit v1.2.3