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

 Define your own Racket function that duplicates the the functionality oflist-ref

Define your own Racket function that duplicates the the functionality oflist-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 "O"). 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 "O", 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 '(4 7 9) 0) (my-list-ref ' (4 7 9) 1) (my-list-ref '(479) 3) ERROR: Index out of bounds

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!