Question: Write the following Scheme functions: 1. makelist - takes a nonnegative integer n and anobject (i.e., an atom or a list) and returns a new

Write the following Scheme functions: 1. makelist - takes a nonnegative integer n and anobject (i.e., an atom or a list) and returns a new list which includes the object repeated n times. For example: (makelist 7 '()) will return (() () () () () () () ) (makelist 3 A ) will return ( A A A ) 2. getDeepOddCount - takes a list of integers, possibly including nested lists, and returns the total number of odd integers in the entire nested list. For example, (getDeepOddCount '(2 3 (4 (7 6) 5))) should return 3. You will find it useful to use the "pair?" function to implement an atom? function. 3. diginlist - takes a list and returns the diggedin version of the list. diggingin a list ( this is not a recognized function for list ??) means surrounding the rightmost and leftmost elements in parenthesis, and repeating the process inwards until the entire list is diggedin. For example: (diginlist '(4 5 3 2 8)) would return (4 (5 (3) 2) 8). You can assume that the input list is "flat", meaning that it doesn't contain any lists. If the input list has an odd number of elements, the center element should be in a list by itself, as shown in the example above. If the input list has an even number of elements, then there should be an empty list in the middle. For example: (diginlist '(4 5 2 8) would return (4 (5 () 2) 8)).

4. unfirl - takes a list of atoms and returns the unfirled version of the list. Unfirling a list means extracting the centermost element and putting it at the front of the list, then repeating the process until the entire list is unfirled. For example, (unfirl '(8 5 9 6 4)) should return the list (9 5 6 8 4). If the list has an even number of elements, the centermost value would be last element of the first half of the list. For example, (unfirl '(7 8 3 4)) would return (8 3 7 4). Note: you may have to define some additional functions to solve this problem.

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!