Write a procedure make-accumulator

Assignment Help Programming Languages
Reference no: EM13186260

Question 1

An accumulator is a procedure that is called repeatedly with a single numeric argument and accumulates its arguments into a sum. Each time it is called, it returns the currently accumulated sum. Write a procedure make-accumulator that generates accumulators, each maintaining an independent sum. The input to make-accumulator will correctly specify the initial value of the sum; for example

(define A (make-accumulator 5))
(A 10)
15
(A 10)
25

Question 2

Write a procedure (make-queue) that produces independent first-in-first-out queue objects, using a message-passing style.

For example:

(define queue1 (make-queue))
(define queue2 (make-queue))

Write procedures to manipulate queues. At a minimum [0.5 marks each]:
1. (queue1 'empty?): boolean
2. (queue1 'enqueue! item): adds item to the queue
3. (queue1 'front): returns the next element of the queue that would be removed on dequeue
4. (queue1 'back): returns the last element of the queue that would be removed on dequeue (i.e. the most recent element added)
5. (queue1 'dequeue!): throws away the front element
6. (queue1 'print): prints some representation of the queue from front to back

Reference no: EM13186260

Questions Cloud

Find the consumer surplus at the new price : Suppose two firms 1 and 2 compete in quantities and face a demand curve p = 100 - q. Suppose firm 1 has a constant marginal cost of 10 while firm 2 has a constant marginal cost of 40. Suppose they produce quantities simultaneously. a. Find q..
State fluoride is toxic element : Fluoride (F-) is toxic element (anion) that can be lethal at 0.20 g/70kg of body weight. But because F- at low levels (1ppm) aids in healthy teeth, municipal water sources normally add this level of fluoride.
Respect to the stock redemption : JKL Corporation redeems 200 of Anna's shares for $1,000 per share. Anna paid $300 per share for her JKL Corporation stock nine years ago. Which of the following statements is correct with respect to the stock redemption?
What is the central angle of a circle wih an arc length : What is the central angle of a circle wih an arc length of 29.21 and the circumference of 40.44 ?
Write a procedure make-accumulator : Write a procedure (make-queue) that produces independent first-in-first-out queue objects, using a message-passing style.
State a water treatment plant flowrate : A water treatment plant has a flowrate of 40,000 m3/d. If the overflow rate is 25 m3/d/m2, determine the following:
Affect the kind of civilization that developed in the area : How did the geography of Greece affect the kind of civilization that developed in the area? (their economic system/ location of cities/ creation of a unified country/ protection and invasion..)
What price does each firm charge : Consider a monopolistically competitive market with N firms. Each firm's business opportunities are described by the following equations: Demand: Q=100/N-P Marginal Revenue: MR=100/N-2Q Total cost: TC=50+Q(squared) Marginal Cost: MC=2Q
How much did she invest in each bond : Kelly Fisher invested a total of $20,000 invested in two municipal bonds that have yields of 7% (bond A) and 9% (bond B) interest per year, respectively. If the interest Kelly receives from the bonds in a year is $1480, how much did she invest in ..

Reviews

Write a Review

Programming Languages Questions & Answers

  Activity for pdus on project management institute-s web site

Several activity categories are given as qualifying for PDUs on project Management Institute's Web site. Recognize  these categories. In which categories would you place Chris's experience?

  Create pseudocode for program to accept insurance data

Create a pseudocode for a program to accept insurance policy holder data, including a policy number, customer last name, customer first name, age, premium due month, day, and year,

  Write function concatenation of two strings as its input

Assume f is function which returns result of reversing string of symbols given as its input, and g is function which returns concatenation of two strings given as its input.

  Program accept word from user and pass it to function

Your program should accept the word from user and pass it to function. Function requires to check if word is "freezing". If it is, program must alert user.

  Write program to read series of pairs of numbers

Write the program which reads series of pairs of numbers (product code and quantity sold) then the program must compute and print the total retail value

  Compare three generations of programming languages

Compare and contrast at least three generations of programming languages. Be sure to include in your discussion: semantics, syntax, and machine dependence.

  Write method that accepts as parameter reference

Write a method maxVal that accepts as parameter the reference to the head node of a linked list of integers. The method should return the largest value in the list.

  Create and write payroll program to prompt user for input

Create and write a payroll program that will prompt the user to enter employee's hourly pay rate and the number of hours worked.

  Calculating hit ratio for program having loops

Calculate hit ratio for program that loops 10 times from locations 0 - 64.

  Pseudocode to create thread-safe countdownevent by locks

Write pseudocode to implement a thread-safe CountdownEvent using locks and condition variables by implementing the following methods (lists 4 methods) and then "implement a Barrier using a CountdownEvent.

  Designing menu for administrator to simulate transmissions

Design a menu which permits administrator to simulate transmissions of information by manually typing in login or logoff data.

  Falling letters game

Generic queue in the first project and generic list in the second project - In the second project, the player clicks the mouse on any falling letter to remove that letter from the window.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd