Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Must be written in Scala PLEASE Write a recursive function filterNumList(1: Numlist, f: Int - Boolean): Numlist that takes in a Numlist and a function

Must be written in Scala PLEASEimage text in transcribed

Write a recursive function filterNumList(1: Numlist, f: Int - Boolean): Numlist that takes in a Numlist and a function f: Int - Boolean 1. It should retum a new list that consist of all elements of the list l that return true when the function f is ca ed on them. 2. The returned list elements must preserve the same order as in the original list. YOUR CODE HERE filterNumList(1: NumList, f: Int Boolean): NumListi val 11 Cons(12, Cons(25, Cons(37, Nil))) def f1(j: Int): Booleanj 25 && j12 val 12 Cons (22, Cons (135, Cons (137, 11))) def f2(j: Int): Boolean j % 5 :: assert( filter-NumLst(12, f2) :: Cons(135, Cons(25, Nil)), "Test 2 failed." def f3(j: Int): Booleanj210 assert(filterNumLst(12, f3) Nil, "Test 3 failed assert(filterNumList(Nil, f3) :: N, "Test 4 failed.") def f4(j: Int): Boolean : j

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mysql Examples Explanations Explain Examples

Authors: Harry Baker ,Ray Yao

1st Edition

B0CQK9RN2J, 979-8872176237

More Books

Students also viewed these Databases questions

Question

Factors Affecting Conflict

Answered: 1 week ago

Question

Describe the factors that lead to productive conflict

Answered: 1 week ago

Question

Understanding Conflict Conflict Triggers

Answered: 1 week ago