Assignment 1
Assignment 2is designed to test your understanding of the second week of CSYE7200lectures, in particular Scalas
mechanism for dealing with lazy values.Furthermore,working through the assignment,you will understand that
features likeStreamsin Scala are not magic.We can create our own, simply using a function
for the lazily-evaluated tail.
You can find the code under theassignment-lazydirectory in the REPO. Make sure you do a pull first.
[21] You are to submit evidence of all unit tests (inLazyListSpec)
passing (use a screenshot). In order to get the tests to succeed, you must implement thefrommethod in the companion object ofLazyList.
Replace the???
//with your own working code. There are plenty of other examples
of similar functionality in theLazyListmodule. Submit, along with your unit test screenshots, the expression that
you used to implement thefrommethod.
Additionally, I want to see answers to the following questions:
(a) [3] what is the chief way by whichLazyListdiffers fromStream(the built-in Scala class that does the same thing). Dont mention the
methods thatLazyListdoes
or doesnt implementI want to know what is thestructuraldifference. (b) [3] Why do you think there is this difference?
[5] Explain whatthe following code actually and why is it needed?
def tail = lazyTail()
[3] List all of the recursive calls that you can find inLazyList(give
line numbers).
[4] List all of the mutable variables and mutable collections that you can find inLazyList
(give line numbers).
[5] What is the purpose of thezipmethod?
[6] Why is there nolength(orsize)method
for LazyList?
Reviews
There are no reviews yet.