Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote