Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write SCHEME program .scm , language R5RS [2 marks] Create a procedure (list->stream lis) that makes a stream from a given list. [3 marks] Create

write SCHEME program .scm , language R5RS

  1. [2 marks] Create a procedure (list->stream lis) that makes a stream from a given list.
  2. [3 marks] Create a procedure (stream->list strm n) that makes a list from the first n items of the given stream.
  3. [2 marks] Create a stream factorials that refers to the infinite stream of consecutive factorial values starting from 0! E.g. (stream-> list factorials 10) (1 1 2 6 24 120 720 5040 40320 362880)
  4. [4 marks] A pseudo-random number generator (prng) can be defined using the following equation:
     Xn+1 = (a*Xn + c) mod m 
    • where m is the "modulus" (0 a is the "multiplier" (0 < a < m), c is the "increment" (0 c < m), and X0 is the "seed" (0 X0 < m) Using this formula, create a procedure called (prng seed) that takes a seed value as argument and produces an infinite stream of random numbers in the range [0,1). E.g.:
       (stream->list (prng 3) 5)  (0.01585 0.4954 0.9988 0.7253 0.0307) 
      Use the following values for the prng constants: m = 232 a = 22695477 c = 1.0 Note: the equation above returns numbers in the range [0,m-1], you should ensure that your stream emits only numbers in the range [0,1)
  5. [2 marks] Create a procedure (random-int r min max) that takes a stream of random numbers r in the range [0,1) and returns a stream of random integers in the range [min,max).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 12th Asian Conference ACIIDS 2020 Phuket Thailand March 23 26 2020 Proceedings

Authors: Pawel Sitek ,Marcin Pietranik ,Marek Krotkiewicz ,Chutimet Srinilta

1st Edition

9811533792, 978-9811533792

More Books

Students also viewed these Databases questions

Question

What advice would you provide to Jennifer?

Answered: 1 week ago

Question

What are the issues of concern for each of the affected parties?

Answered: 1 week ago