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

  Routers

Discuss in detail why the differentiated services (DS) domain comprises of the set of contiguous routers? Also explain how the boundary node routers are different from interior node routers in the DS domain.

  Design visual basic 2010 program to analyze a mortgage

Write down a Visual Basic 2010 program to analyze a mortgage. The user should enter the amount of the loan, the annual rate of interest, and the duration of the loan in months.

  Test a program that generates 1000 random numbers

write and test a program that generates 1000 random numbers between 1 and 6 and stores them in a data file.Write down a second program the takes the data produced by the first program and analyses it to produce a table showing the number of times ..

  Build a java program named comparefiles.java

make a java program named CompareFiles.java and enter the code to check if the files, TeamProj.txt and TeamProj2.txt, exist.

  How to modify bob''s behaviour to prevent this threat

imagine we are using Lamport's hash, and Bob's system crashes before receiving Alice's reply to a message. Further suppose an intruder, Trudy, can eavesdrop and detect that Bob crashed (maybe Trudy can even cause Bob to crash).

  Why need both kinds of routing protocols

consider the difference between an interior routing protocol and an exterior routing protocol. What are they, how are they both similar and different.

  Define the quicksort algorithm to sort vector v

define the quicksort algorithm to sort vector v. During each pass, list all exchanges of a pair of elements in the lower and upper sublist.

  Design a detail report that will display all courses

make a switchboard design with control buttons that lead to students, instructors, courses, course schedules, and course rosters. Allow a user to add, update, or delete records in each area. Jesse wants to see storyboards that show the proposed sc..

  Developing the java program

Write down a program in java to input the basic salary of 15 persons. Each one of them receives 25% of basic as hra (house rent allowance), 15 % of the basic as conveyance and 10 % of the basic as an entertainment allowance.

  Guassian function and digital transmission technique

Prove the following properties of Gaussian function:Explain four benefit and one de-merits of utilizing the digital (rather than the analog) techniques for transmission of the voice-telephone signals.

  Define the spirit of the recursion theorem of a program

define the spirit of the recursion theorem of a program.

  Find out all doctors who went to harvard

Did the SQL programmer enforce the constraint that every doctor practices in a unique hospital? If so, how? If not, how do you know, and how, if at all, might this constraint have been implemented.

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