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

  Algorithm for finding two closest numbers in the input list

plan an algorithm for finding two closest numbers in the input list. What is the time complexity? Is it possible to improve the algorithm if the input is a sorted list.

  What role might the reticular activation formation play

What role may the "Reticular Activation Formation" play in the AROUSAL process.

  What levels of osi model tcp/ip functions

in brief answer to explain at what levels of the OSI model TCP/IP functions.

  Explain the sum of the inverses of all positive integers

though , when we compute the sum in Java's floating point arithmetic the largest value we get is 15.403683, regardless of how many terms we add. Explain the possible reasons for this anomaly.

  Give employee''s pay according to that employee''s pay code

A company pay its employees as managers (who receive a fixed weekly salary), hourly workers (who receive a fixed hourly wage for up to the 40 hours they work and "time-and-a-half"- 1.5 times their hourly wage- for overtime hours workers).

  What is the polymorphic assingment

Why do C++'s capabilites of (polymorphism, encapsulation, inheritance) make programming difficult?what is the polymorphic assingment.

  Choose the employee''s last name

Group employees by salary within their job code: choose the employee's last name and group them by salary within their job_title_code.

  Should pharmacies make available to the public

Does the Ministry of Health have a moral responsibility to educate the population about the risks involving the use of generic drugs Should pharmacies make available to the public the list of CDAP drugs which are generic

  Variables reduce unnecessary comparision in a bubble sort

when merging 2 files, what condition terminates the main loop of the program.What type of variables can be used to reduce unnecessary comparision in a bubble sort.

  Metric conversion program

Write down a javascript which will assist user along with the metric conversions. Your program must enable the user to state the names of units as strings.

  Write down a program using the vector class

create a program using vector class that allows the user to input the number of days worked in a 7 day workweek and, using a fixed hourly rate, calculates the weeks wages and the average number of hours worked per day.

  Which will be executed had these names

How would I write down a shell script to locate executable files? This script takes a list of file names from the command line and determines which would be executed had these names been given as commands.

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