Write an ML (SML; Standard Meta Language) function getith(i,L) that takes an int
ID: 3591804 • Letter: W
Question
Write an ML (SML; Standard Meta Language) function getith(i,L) that takes an integer i and a list L, and returns the ith element on list L. Write exception definition, raise and handler if i is < 1 or if i > length of L.Write an ML (SML; Standard Meta Language) function getith(i,L) that takes an integer i and a list L, and returns the ith element on list L. Write exception definition, raise and handler if i is < 1 or if i > length of L.
Write an ML (SML; Standard Meta Language) function getith(i,L) that takes an integer i and a list L, and returns the ith element on list L. Write exception definition, raise and handler if i is < 1 or if i > length of L.
Explanation / Answer
fun getith =
if i<1 or i>len(L) then raise Exception('ut of range error') else return L[i]
#Calling of ML Function
getith = i,L
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.