Write a function that produces of positive prime numbers

Assignment Help Computer Engineering
Reference no: EM13316940

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)

<your code here>)

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 */

Reference no: EM13316940

Questions Cloud

What is max depth that can be safely reached for drilling : If the pipe is designed with a safety factor of two [i.e. the maximum stress in the field must be less than half the rated yield stress], what is the maximum depth that can be safely reached for drilling.
To what tension must the wire be tightened : A steel wire on a guitar has a length of 0.500 m and a mass of 3.50 x 10^-3 kg. To what tension must the wire be tightened
What is the probability that both rain and lightning occur : Let event Y be a rainstorm on a given day and event X be lightning on a given day. Let probability of these events be: P(X)=0.3 P(Y)=0.1 P(Y|X)=0.5 What is the probability that both rain and lightning occur on a given day
Find the acoustic power emitted by the howler : The howler monkey is the loudest land animal and can be heard upto a distance of 2.5 km. The acoustic power emitted by the howler, in mW is
Write a function that produces of positive prime numbers : 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.
What frequency do you hear after it passes by you : A police car is moving towards you at a speed of 36.0 m/s. Its siren produces a frequency of 850 Hz. What frequency do you hear after it passes by you
Determine the axial forces in the members of the truss : A cable is attached at A and is connected to the wall. Determine the axial forces in the members of the truss using the Method of Joints and indicate whether they are in tension (T) or compression (C). Be sure to provide complete free body diagram..
How far away was the lightning bolt : Thunder is heard 4.0 sec after the flash of lightning is observed. If the outside temperature is 15 degrees celsius, how far away was the lightning bolt
Advise periwinkle of its fbt consequences arising out : Advise Periwinkle of its FBT consequences arising out of the above information, including calculation of any FBT liability, for the year ending 31 March 2014 and how would your answer to (a) differ if Emma used the $50,000 to purchase the shares h..

Reviews

Write a Review

Computer Engineering Questions & Answers

  Use apa format and have a list of references

As you are aware a software product license grants individuals the legal right to run or access a software program. A license agreement governs the use of the licensed software program. One of the ongoing sagas in Information Technology is the que..

  Write down an application that plays "guess the number"

Write an application that plays "guess the number" as follows: Your application chooses number to be guessed by selecting an integer at random in range 1-1000.

  Generating the printstream object

Generate a PrintStream object utilizing the dos and allocate the resulting reference to ps, a PrintStream variable which has already been declared.

  Express the advantages of joining two tables

express the advantages of joining two tables.What is the inner join and what is outer join? Please give me some real applications of joins.

  How dedicated technician to maintain your wan interfaces

When there is a network outage, how do companies find out the network boundary.

  Define the layers of the international organization

The layers of the International Organization for Standardization-Open Systems Interconnection (ISO-OSI) model.

  Make use to effectively manage a team of system

Are different management techniques needed for managing technical personnel versus nontechnical personnel.

  Installing the new network

You have been hired as an IT Consultant in order to assist Good Nature food market with developing and implementing the new network. They have hired you to find what type of network they required and to install the network.

  Similarities and differences to issue of regulation

Describe the relevance of each of these similarities and differences in order to issue of regulation of the Internet.

  Where is the reason of most of the attacks

Where is the reason of most of the attacks.explain the differences between the two main classes of intrusions: misuse and anomaly.

  How to create a database for music

How to create a database for music? Other entities will be Artist/Group - Attributes will be Name, Year Founded, Origin, Tones and Biography, Track - Attributes will be Number and User's Recommendation and finally Song - Attributes will be Name, ..

  Code to declare the four pointer variables

In C++: A pointer variable may consist of a pointer to a valid object, a pointer to a deleted object, NULL, or the random value. Write down the code which generates and sets four pointer variables a, b, c, and d to display each of these possibilit..

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