erwise. Write a function called odd which returns true if the integer argument is odd, false otherwise. Now create five streams: squares, fibs, evenFibs, oddFibs, and primes. squares contains the sequence of perfect squares starting from 1. You may find the map function helpful to create such a stream. Then, create a stream called fibs that contains the Fibonacci sequence. evenFibs and oddFibs are similar but they only contain the even Fibonacci numbers and odd Fibonacci numbers, respectively. The last stream is primes, which has the sequence of prime numbers. Write a function called rev_zip_diff which will zip together two streams in reverse order (hint: take a look at how the zip function works that we went over in class) and leverage an arbitrary difference function to obtain the difference of every two elements. rev_zip_diff should have the following type signature: val zip 'a stream -> 'b stream -> ('b 'a -> 'c)-> ('b* 'a * 'c) stream You may wish to test rev_zip_diff by zipping together evenFibs and oddFibs and a function that gets the integer difference, and then create a concrete list with the take function. 4 Generalized Printing You are tasked with creating generalized list printing functions. Write a function called print GenList which takes a list and a printing function f and applies the function to each element of the list recursively. The function should have the following type signature: val print GenList : 'a list-> ('a -> unit) -> unit Create a function called printList that will pretty print an integer list. You will find the string concatenation operator (^) and the string_of_int function useful. printList will take an integer
erwise. Write a function called odd which returns true if the integer argument is odd, false otherwise. Now create five streams: squares, fibs, evenFibs, oddFibs, and primes. squares contains the sequence of perfect squares starting from 1. You may find the map function helpful to create such a stream. Then, create a stream called fibs that contains the Fibonacci sequence. evenFibs and oddFibs are similar but they only contain the even Fibonacci numbers and odd Fibonacci numbers, respectively. The last stream is primes, which has the sequence of prime numbers. Write a function called rev_zip_diff which will zip together two streams in reverse order (hint: take a look at how the zip function works that we went over in class) and leverage an arbitrary difference function to obtain the difference of every two elements. rev_zip_diff should have the following type signature: val zip 'a stream -> 'b stream -> ('b 'a -> 'c)-> ('b* 'a * 'c) stream You may wish to test rev_zip_diff by zipping together evenFibs and oddFibs and a function that gets the integer difference, and then create a concrete list with the take function. 4 Generalized Printing You are tasked with creating generalized list printing functions. Write a function called print GenList which takes a list and a printing function f and applies the function to each element of the list recursively. The function should have the following type signature: val print GenList : 'a list-> ('a -> unit) -> unit Create a function called printList that will pretty print an integer list. You will find the string concatenation operator (^) and the string_of_int function useful. printList will take an integer
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
OCaml Code: Attached are the instructions and below is the example output. Make sure to read the instructions carefully. There must be no error in the code at all and show the screenshots of the correct code and output. Be sure to write your own test cases as well and test them. I need to make sure the code works 100%.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education