Write a function called stream-map

Assignment Help Programming Languages
Reference no: EM13335234

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: EM13335234

Questions Cloud

Write function that produces a stream 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.
Should we try and completely eliminate unemployment : When the U.S. economy is at full employment, why isn’t the unemployment rate at zero percent? Should we try and completely eliminate unemployment?
What should be average beta of new stocks added to portfolio : Assume that the risk free rate is 4.5% and that the market risk premium is 5.5%. The manager expects to receive an additional $5,000,000 in funds soon.
Brazils popluation will double in about : Over the past 50 years , Brazils population growth rate has average about 2.3 percent. According to the rule of 70, Brazils popluation will double in about ?
Write a function called stream-map : 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.
Is the value of intermediate goods and services included : Why must the total value of expenditures in the economy be equal to total income? Is the value of intermediate goods and services included in GDP? Explain.
What is general industries expected current share price : general industries is expected to generate $22 million, $26 million, $29 million, $30 million, and $32 million in free cash flows over the next five years, after which free cash flows are expected to grow at a rate of 3% per year.
Find the minimum power rating of the car : An electric car accelerates for 11 s by drawing energy from its 270-V battery pack. Find the minimum power rating of the car
Determine what is the companys wacc of par : The first bond issue has a face value of $85 million, has a 7 percent coupon, and sells for 97 percent of par. The second issue has a face value of $50 million, has an 8 percent coupon, and sells for 108 percent of par.

Reviews

Write a Review

Programming Languages Questions & Answers

  Smallest number using class-friend function and overloading

C++program which can neither be two integers or two floating point number and output smallest number using class, friend function and overloading.

  Program that uses for loop prompt user to input two integers

Write a program that uses for loop to preform the following steps: Prompt the user to input two integers: firstnum and secondnum.

  Write application layer protocols to permit through firewall

As part of your own planning process, write the application layer protocols which you would permit through the firewall, those you would block and your reasons for doing so.

  Program to swap values from variables

Given two int variables, firstPlaceWinner and secondPlaceWinner , write some code that swaps their values. Declare any additional variables as necessary.

  Design and develop a unix file sharing system

Design and develop a UNIX file sharing system. For this task you will be required to develop a simple application in C programming language.

  Write recursive function to return maximum element of array

Write down the recursive function which receives three parameters: The recursive function must return maximum element of array.

  Probability line is executed in nth iteration of for loop

What is the probability that line is executed during the nth iteration of the for loop? What is the exact expected number of executions of line?

  Application where you ask the user to input the price

Write an application where you ask the user to input the price per letter (PPL), and then ask the user to input the sentence they want printed. The application should then calculate the number of letters and give the user the total cost in the follow..

  Write method to display the number by adding hundred

displayItTimesTwo(), and displayItPlusOneHundred(). Write each method to perform the task its name implies. Save the application as TestMethods.java.

  Design logic that continuously prompt user for numeric value

Design the logic for a program that continuously prompts a user for a numeric value until the user enters 0. The application passes the value in turn to a method that squares the number

  Decrypt all entries of username variable

Need a another cgi file to decrypt all entries of ' username ' variable and restore it to original plain/text, it should be start restoring the inputs to original text the cgi file

  Program to use next character to create and return operator

Convert the string of digits into an integer. Otherwise, use the next character to create and return an operator.

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