please complete using the SCHEME programming language. The maxInt function takes
ID: 3862929 • Letter: P
Question
please complete using the SCHEME programming language.
The maxInt function takes a list of numbers, and returns its maximum element. For example, (maxInt' (7 3 6 2)) should return 7. If the input list is empty, then it should return 0. Write the maxInt function in Scheme in two steps: (a) Write a maxInt_helper function; it takes a number k and a list of numbers, x, as arguments, and returns the number which is the largest among k and numbers in x. For example, (maxInt_helper 5' (4 5 6)) should return 6. (b) Write the maxInt function based on maxInt_helper.Explanation / Answer
Python 2.7 code:
def maxIntHelper(n,l):
maxx = n
for i in range(0,len(l)):
if(maxx < l[i]):
maxx = l[i]
return maxx
def maxInt(l):
return maxIntHelper(0,l)
print maxInt([7,3,6,2])
print maxInt([])
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.