Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions

Question

=+ (c) The same, but suppose that 22 is uncountable.

Answered: 1 week ago

Question

Different types of Grading?

Answered: 1 week ago

Question

Explain the functions of financial management.

Answered: 1 week ago

Question

HOW MANY TOTAL WORLD WAR?

Answered: 1 week ago

Question

Discuss the scope of financial management.

Answered: 1 week ago