2018-12-04 17:18:32 +00:00
|
|
|
from Maths.abs import absVal
|
|
|
|
|
2018-11-03 20:08:13 +00:00
|
|
|
def absMax(x):
|
|
|
|
"""
|
2018-12-04 17:18:32 +00:00
|
|
|
#>>>absMax([0,5,1,11])
|
2018-11-03 20:08:13 +00:00
|
|
|
11
|
|
|
|
>>absMax([3,-10,-2])
|
|
|
|
-10
|
|
|
|
"""
|
2018-12-04 17:18:32 +00:00
|
|
|
j =x[0]
|
2018-11-03 20:08:13 +00:00
|
|
|
for i in x:
|
2018-12-04 17:18:32 +00:00
|
|
|
if absVal(i) > absVal(j):
|
2018-11-03 20:08:13 +00:00
|
|
|
j = i
|
|
|
|
return j
|
|
|
|
#BUG: i is apparently a list, TypeError: '<' not supported between instances of 'list' and 'int' in absVal
|
2018-12-04 17:18:32 +00:00
|
|
|
#BUG fix
|
2018-11-03 20:08:13 +00:00
|
|
|
|
|
|
|
def main():
|
2018-12-04 17:18:32 +00:00
|
|
|
a = [-13, 2, -11, -12]
|
|
|
|
print(absMax(a)) # = -13
|
2018-11-03 20:08:13 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|
2018-12-04 17:18:32 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
print abs Max
|
2018-12-04 17:32:53 +00:00
|
|
|
"""
|