Question: This This is in Scala will rate thanks! Problem 3 (20 points) A (10 points) We defined lists in the class as an inductive datatype.

This
This is in Scala will rate thanks!
Problem 3 (20 points) A (10 points) We defined lists in the class as an inductive datatype. Let's define a NumOption type for functions with optional return values (such as Some (2) or None ). See note on option types as the inspiration for NumOption: https://www.geeksforgeeks.org/scala-option/ We will use the following grammar: NumOption None denotes the lack of a value | Some(Integer) denotes an integer value First define, the NumOption datatype following the grammar above. Next write a recursive function that returns the nth element of the list. However, if the list size is smaller than n you should return a None signalling no element can be found or otherwise Some(x) where x is the nth element. Also, if n Boolean): NumList that takes in a NumList and a function f: Int => Boolean 1. It should return a new list that consist of all elements of the list 1 that return true when the function f is called on them. 2. The returned list elements must preserve the same order as in the original list. : // YOUR CODE HERE ??? Problem 3 (20 points) A (10 points) We defined lists in the class as an inductive datatype. Let's define a NumOption type for functions with optional return values (such as Some (2) or None ). See note on option types as the inspiration for NumOption: https://www.geeksforgeeks.org/scala-option/ We will use the following grammar: NumOption None denotes the lack of a value | Some(Integer) denotes an integer value First define, the NumOption datatype following the grammar above. Next write a recursive function that returns the nth element of the list. However, if the list size is smaller than n you should return a None signalling no element can be found or otherwise Some(x) where x is the nth element. Also, if n Boolean): NumList that takes in a NumList and a function f: Int => Boolean 1. It should return a new list that consist of all elements of the list 1 that return true when the function f is called on them. 2. The returned list elements must preserve the same order as in the original list. : // YOUR CODE HERE
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
