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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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