Write in Scala for the following assignment: Define a function named contains th
ID: 3823943 • Letter: W
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 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).Explanation / Answer
Hi, Please find my implementation.
Please let me know in case of any issue.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.