Question: Language: racket Create a function repeated that takes two arguments: a function f of one argument and a non-negative integer count. The result should be

Language: racket

Create a function repeated that takes two arguments: a function f of one argument and a non-negative integer count. The result should be a function of one argument, to which it applies the function f count times. Here is a sample transcript, of course not showing repeated:

(define (add-one n)

(+ 1 n))

(define add-one-five-times

(repeated add-one 5))

(test (add-one-five-times 10) 15)

(test (add-one-five-times 0) 5)

----------------------------------------------

good (add-one-five-times 10) at line 16

expected: 15

given: 15

good (add-one-five-times 0) at line 17

expected: 5

given: 5

Turn in your repeated function and a transcript of this and other tests, either using test or by explaining in your write-up the answer you expect (remember that to use test, you must write #lang plai at the top of the definitions pane).

Your tests should not all use add-one-five-times. Make your own calls to repeated also with a different function and counts.

Explain what repeated should return if its numeric argument is 0 and why.

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!