Example on message-passing style

Assignment Help Programming Languages
Reference no: EM13190378

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 [2 marks]. 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.

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: EM13190378

Questions Cloud

Evaluate the importance of being an agile coach : Evaluate the importance of being an agile coach on the project team and analyze the key roles the agile coach plays in team communication and facilitation activities.
Do change in fixed costs does affect firms level of ouyput : Suppose that a firm sells in a highly competitive market, in which the going prince is $15 per unit. its cost equation is c=$25+.25Q^2 find the profit-maximizing level of out put for the firm. determine its level of profit.
Use the poisson distribution to find indicated probability : Use the Poisson Distribution to find the indicated probability.
Use the poisson model to approximate the probability : Use the Poisson model to approximate the probability. Round your answer to four decimal places.
Example on message-passing style : Write a procedure that produces independent first-in-first-out queue objects, using a message-passing style.
Use the poisson model to approximate the probability : Use the Poisson model to approximate the probability. Round your answer to four decimal places.
Determine the critical values of r : Given the linear correlation coefficient r and the sample size n, determine the critical values of r and use your finding to state whether or not the given r represents a significant linear correlation. Use a significance level of 0.05.
Calculate the explicit costs of the firm : During a year of operation, a firm collects $175,000 in revenue and spends $80,000 on raw materials, labor expenses, utilities and rent. The owners of the firm have provided $500,000 of their own money to the firm (and view that money as a loan to..
Discusses several methods of studying human behavior : The text discusses several methods of studying human behavior. These include the case study, naturalistic observation, correlational research, survey research, and the experimental method.

Reviews

Write a Review

Programming Languages Questions & Answers

  Explaining graphics as user experience on web sites

Graphics provide significant richness to the user experience on web sites. Discuss how each of these sites uses graphics in good or poor ways.

  Write a set-list of enumerated constants for week

Write a set/list of enumerated constants called week which contains days of the week. Have variable called today that is of type week. Allot value to today.

  Program to output circle-s radius-diameter-circumference

Write a program to prompt the user to enter center and a point on circle. Program must then output circle's radius, diameter, circumference, and area.

  Create method to calculate value of product purchase

In addition, the receipt should display the value of the entire purchases. Create a method to calculate the value of the product purchases.

  Design application to calculate and show price of order

Design the application to calculate and show the price of order, based on number of units ordered and the customer's status (either wholesaler or retailer).

  Program for saving account balance report

Savings account balance report from customer savings account file. Every input savings account record contains account number, balance forward, deposits (sum of all deposits).

  Give greedy algorithm to get all n people across bridge

Give a greedy algorithm to get all these n people across the bridge in a fastest way. Describe the algorithm briefly. Prove the correctness.

  Two-dimensional array to store weekly hours for employees

Assume the weekly hours for all employees are stored in two-dimensional array. Each row records emaployee's seven-day workhours with seven columns.

  Design an appropriate set of classes to solve the problem

The purpose of this project is for you to demonstrate your understanding of object oriented software development in practice.

  Write program to calculate and output tuition

Write a C++ program to calculate and output tuition. Prompt user for number of credits taken and type of classes ('U' for undergraduate - $380 per credit hour, or 'G' for graduate.

  Write a program to enter any number of integers in array

Write a program which permits a user to enter any number of integers, which are then stored in the array. After user enters integers, perform the following operations on array.

  Distinguishing web pages or web servers for task

Distinguish between any Web pages or Web servers you would use for this task.

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