Question: Define your own Racket function that duplicates the the functionality of list-ref from the standard library. You may not use the built-in list-ref function

Define your own Racket function that duplicates the the functionality of list-ref from the standard library. You may not use the built-in list-ref function as a helper function. Define a function that takes a list and an integer. The function should return the list element at the integer number (first list position is index "0"). If the integer is larger than the index of the last list member, it should display an "index out of bounds" message. Your implementation must be recursive. Input: A list of elements of any data type, potentially heterogenous, and a single integer. Output: A single element from the original list that is at the "index" indicated by the integer. The first list position is position "0", the second list position is "1", etc. If the integer is greater than the number of list elements, the function should throw an error (using the error function) with the message string "ERROR: Index out of bounds". Example: > (my-list-ref (479) 0) 4 > (my-list-ref (479) 1) 7 > (my-list-ref (479) 3) ERROR: Index out of bounds
Step by Step Solution
There are 3 Steps involved in it
Heres a recursive implementation of the mylistref function in Racket racket define mylistref lst ... View full answer
Get step-by-step solutions from verified subject matter experts
