Suppose you have a scheme function that counts the number


Problem 1 - Recursion and Iteration
Write a function that converts a decimal input into Roman Numerals. Your function will take in a number and output a string. You will want to make use of the function string-append, which concatenates two (or more) strings together into a single string with no spaces.
(string-append "ab" "cde") => "abcde"

In Roman Numerals, M = 1000, D = 500, C = 100, L = 50, X = 10, V = 5, and I = 1. Combinations of letters next to each other change the total value depending on order. For example, XL = 40, VIII = 8, and MCCXLI = 1241. 

(1a) Write a recursive version of this function. 

(1b) Write an iterative version of this function. 


Problem 2 - Procedures as Parameters and Return Values 
(2a) Suppose you have a Scheme function that counts the number of patient visits in a certain town to a mobile medical clinic. The clinic visits the town occasionally, so for most days the number of patient visits will be 0. You have data for 128 days.

For this problem you will write a Scheme procedure that takes in (i) a function f, that gives the number of patient visits on each day from day 1 to day 128 (at least 20 days worth of data), (ii) an integer a, the start day of your range, and (iii) an integer b, the end day of your range, and returns the average number of patients visits for the days when the clinic was in town.

Example: suppose the patient visit function is as follows:

(define (visits n)
(cond ((= n 10) 20)
((= n 18) 18)
((= n 39) 52)
((= n 52) 12)
((= n 78) 23)
((= n 88) 34)
((= n 103) 18)
((= n 111) 11)
((= n 126) 33)
(else 0)))

Then your procedure applied to visits, a = 19 and b = 78 should return 29 because there are 3 days with patient visits during the range, and (52 + 12 + 23) / 3 = 29.

(2b) Collatz Conjecture
Write a Scheme program which solves the Collatz Conjecture, otherwise known as the 3n+1 problem. It works as follows:

Given an integer n, test to see if n is even or odd.
If n is even, divide it by 2; if it is odd multiply by 3 and add 1 (3n+1).
Repeat this process on the new n.

Write a procedure (collatz) which will return a procedure that goes through the integers from n down to 1 according to the above formula. It will then display a congratulatory message saying the program has finished. The catch is, this must be done using only procedures which return procedures and not as one large procedure like you've used thus far in the course.

Things to be aware of:
You must display every value, but when you do so is up to you.
They must be procedures which return procedures, and not simple expressions.
You need to write your own test-cases-be thoroug 

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Suppose you have a scheme function that counts the number
Reference No:- TGS0119580

Expected delivery within 24 Hours