Question: Write in Scala for the following assignment: Define a function named contains that takes an integer and a list of integers as parameters. The function

Write in Scala for the following assignment:

Write in Scala for the following assignment: Define a function named contains

Define a function named contains that takes an integer and a list of integers as parameters. The function should return true if the element is in the list, false otherwise. For example: contains 3, List 2, 4, 6, 8)) = false contains(9, List()) = false contains(3, List(6, 3, 3, 2)) = true Test your code using the interpreter on stdlinux to check your work. As above, use only the elements we have discussed in class to write this code and your solution must be done without using a while loop. (As an exercise, try implementing this with Scala's match/case syntax instead of using if else)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!