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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started