Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Code Style and Testing

?     All code has been well indented and has been broken down into reasonably sized procedures (no single line should be too long; aim for about 80 characters each)

?     Each procedure has been well documented (but not over-documented - don't just restate the code) with comments, including the purpose of the procedure, the expected inputs, and the expected output.

?     When appropriate (Questions 1 and 2), there is sufficient testing using check-expect (or other check functions) and, at a minimum, no code is highlighted by DrRacket when the file is run.

Question 1

Write a function that produces a stream of positive prime numbers. Use that stream to create a list of the product of all pairs of consecutive prime numbers up to a given value.

For example, if we want the answer for prime numbers up to 20, the prime numbers are:

2, 3, 5, 7, 11, 13, 17, 19

The output list would be:

'(6, 15, 35, 77, 143, 221, 323)

Question 2

Write a function called stream-map :

(define (stream-map proc . argstreams)

)

The proc argument is the procedure to apply to one or more streams, while argstreams is a list of a variable number of streams to be used with proc.

Now write a function that uses stream-map to produce the sum of two streams element by element for the first x elements.  Be sure to test with several different types of streams (for example, you could sum together the odd and even numbers between 1 and x).

Question 3

Using Prolog, establish a database of facts and rules for the following predicates:

father(X,Y) /* X is the father of Y */

mother(X,Y) /* X is the mother of Y */

male(X) /* X is male */

female(X) /* X is female */

parent(X, Y) /* X is the parent of Y */

difference(X,Y) /* X and Y are different */

 

Write Prolog clauses to define the following relationships:

is_mother(X) /* X is a mother */

is_father(X) /* X is a father */

aunt(X, Y) /* X is an aunt of Y */

uncle(X, Y) /* X is an uncle of Y */

sister_of(X,Y) /* X is a sister of Y */

grandfather_of(X, Y) /* X is a grandfather of Y */

grandmother_of(X, Y) /* X is a grandmother of Y */

grandchild(X,Y) /* X is a grandchild of Y */

sibling(X,Y) /* X is a sibling of Y, i.e they have the same parents */

half_sibling(X,Y) /*they have same mother but different fathers or

same father, different mothers */

related(X,Y) /* X is related to Y */

ancestor(X, Y) /* X is an ancestor of Y */

descendant(X,Y) /* X is a descendant of Y */

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9896251
  • Price:- $60

Priced at Now at $60, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Python programmingplease i would like some help in checking

Python programming Please I would like some help in checking if my source code for is susceptible to short-circuit evaluation.I don't need answers, I just need corrections. The source code is to check the integer parts o ...

Assume newspaper for garbage or recycling has a standard

Assume newspaper for garbage or recycling has a standard deviation of 2 pounds. If we want to estimate the average amount of newspaper for garbage or recycling within .25 pounds with 90% confidence, how many households m ...

A very skilled court stenographer makes two typographical

A very skilled court stenographer makes two typographical errors (typo) per hour, on average. 1. What probability distribution is most appropriate for calculating the probability of a given number of typos being made by ...

Take the input of numbers and reverse the order of elements

Take the input of numbers and reverse the order of elements in that vector using recursion.

Scheduling algorithms are again becoming more important as

Scheduling algorithms are again becoming more important as we look at operating system that run on mobile devices. Are their scheduling algorithms different from those found on traditional interactive system? Compare and ...

Calculate the probability of selecting a random sample of

Calculate the probability of selecting a random sample of 225 observations with a sample proportion of 0.54 or greater, if the sample population has a population proportion of 0.50.

Consider a project to supply 97 million postage stamps per

Consider a project to supply 97 million postage stamps per year to the U.S. Postal Service for the next five years. You have an idle parcel of land available that cost $1,690,000 five years ago; if the land were sold tod ...

Question please review the description of the organization

Question: Please review the description of the organization that is the subject of your semester project. The description of that organization, CITY GENERAL HOSPITAL, is described in the instructions for Phase I that you ...

Suppose a life insurance company sells a 230000 one-year

Suppose a life insurance company sells a $230,000 ?one-year term life insurance policy to a 20?-year-old female for ?$330. The probability that the female survives the year is 0.999642. Compute and interpret the expected ...

Suppose a particular fa called fin has the property that it

Suppose a particular FA, called FIN has the property that it had only one final state that was not the start state. During the night, vandals come and switch the + sign with the - sign and reverse the direction of all th ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As