Your Perfect Assignment is Just a Click Away

We Write Custom Academic Papers

100% Original, Plagiarism Free, Customized to your instructions!

glass
pen
clip
papers
heaphones

USFCA Tracing and Higher Order using Lambda Racket Code

USFCA Tracing and Higher Order using Lambda Racket Code

Description

1.

(define my-list (list 1 2 3 4))

(define (foo x)

(lambda (y)

(if (even? (+ x y))

(lambda (z) (* z 2))

(lambda (z) (* z 3)))))

(define (bar ls)

(if (empty? ls)

‘()

(cons ((car ls) 10) (bar (cdr ls)))))

Why is the output ‘(20 30 20 30)? To answer this question, trace and/or explain in detail the evaluation steps of (bar ( map (foo 3) my-list)) to show how the output ‘(20 30 20 30) is produced.

2.

A recursive, but not higher order function viral-growth that returns a list of the minute-by-minute growth when one person spreads a video to three other people per minute:

(define (viral-growth mins ppl)

(if (= 0 mins)

‘()

(cons (* 3 ppl) (viral-growth (- mins 1) (* 3 ppl)))))

> (viral-growth 4 1)

‘(3 9 27 81)

And a higher order function repeated that returns another function, f, applied count times:

(define (repeated f count)

(lambda (x)

(if (= count 0)

x

(f ((repeated f (- count 1)) x)))))

> ((repeated add-one 3) 1)

4

Rewrite viral-growth so that it can be passed to repeated and so that the count variable of repeated (rather than a mins variable in viral-growth) determines how many minutes of viral growth pass. Rewrite viral-growth to accept only one argument, the number of people who start the spread, and to return a lambda that accepts a list argument.

(define (viral-growth ppl)

(lambda (ls)

… your code goes here …

If you rewrite viral-growth correctly, you should be able to pass it to repeated as follows:

> ((repeated (viral-growth 1) 4) ‘())

‘(3 9 27 81)

An answer that returns the list in reverse order ‘(81 27 9 3) will be accepted but with an automatic deduction of 3 points. Also, do not use any built-in function except for empty?, *, cons, car, or cdr.

Order Solution Now

Our Service Charter

1. Professional & Expert Writers: School Class Pro only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by School Class Pro are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. School Class Pro is known for timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At School Class Pro, we have put in place a team of experts who answer all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.