diff options
author | Matthew Strapp <msattr@gmail.com> | 2019-09-29 17:34:21 -0500 |
---|---|---|
committer | Matthew Strapp <msattr@gmail.com> | 2019-09-29 17:34:21 -0500 |
commit | a4c13834fb5093c8b3cd5eef5d65a6c99ee6b9c9 (patch) | |
tree | 689410f5d905a42eae626a99ae4a6215d3accd8c /csci1913 | |
parent | E (diff) | |
download | homework-a4c13834fb5093c8b3cd5eef5d65a6c99ee6b9c9.tar homework-a4c13834fb5093c8b3cd5eef5d65a6c99ee6b9c9.tar.gz homework-a4c13834fb5093c8b3cd5eef5d65a6c99ee6b9c9.tar.bz2 homework-a4c13834fb5093c8b3cd5eef5d65a6c99ee6b9c9.tar.lz homework-a4c13834fb5093c8b3cd5eef5d65a6c99ee6b9c9.tar.xz homework-a4c13834fb5093c8b3cd5eef5d65a6c99ee6b9c9.tar.zst homework-a4c13834fb5093c8b3cd5eef5d65a6c99ee6b9c9.zip |
Finish Lab because I stoopid
Diffstat (limited to 'csci1913')
-rw-r--r-- | csci1913/Python/lab3_strap012.py | 24 |
1 files changed, 12 insertions, 12 deletions
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) # |