Homework 1 Solution

$35.00 $29.00

1. Define a tail recursive function in Scala that can search an array of integers. You need to fully test your function. (10 pts) 2. Define a tail recursive function in Scala that can search a list of integers. You need to fully test your function. (10 pts) 3. Learn how the function findFirst is…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

1. Define a tail recursive function in Scala that can search

an array of integers. You need to fully test your function. (10 pts)

2. Define a tail recursive function in Scala that can search

a list of integers. You need to fully test your function. (10 pts)

3. Learn how the function findFirst is created on page 23 in the book of Functional Programming.

Create a function findLast. You need to fully test your function. (10 pts)

4. Create a class named State which has sayHelloLocal() and sayHelloGlobal().

sayHelloLocal() will display the number of times that you call it in each object of State,

but sayHelloGlobal() will display the number of times that you call it in all objects of State.

You need to fully test your class. (10 pts)

5. On page 37 in our textbook, there is an example of using groupBy. You will practice

how to use this method again here: create a class named Person which has first name and last

name, then create a list of Persons and use groupBy to group the list by first name or by last name. You need to fully test your code. (10 pts)

6. Create a class named Student which has name, major, and GPA. Create a list of Students and then compute the average GPA by major, finally sort different majors by their average GPA. (10 pts)

On page 183 in the book of ‘Scala for the impatient’, there is an example of using groupBy.

This method yields a map whose keys are the function values, and whose values are the

collection of elements whose function value is the given key.

Homework 1 Solution
$35.00 $29.00