Question: Write a function apply-count that takes two arguments, f and x. It returns a pair whose car is the value of (f x) and
Write a function apply-count that takes two arguments, f and x. It returns a pair whose car is the value of (f x) and whose cdr is the total number of times apply-count has been called, including the current call. For full credit you may not use global state. Here is an example transcript with a fresh DrRacket session. > (apply-count (lambda (x) (* x x)) 5) (25. 1) > (apply-count (lambda (x) x) 100) (1002) > (apply-count (lambda (x) x) 100) (100. 3) Hint: Write a version using global state first. Then review the "let over lambda " technique from lecture and modify your implementation so that it uses only local state.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
