Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.
ThisThis 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 HEREStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started