How to separate even and odd numbers in a List of Integers in Scala

Hey there!

Welcome to ClearUrDoubt.com.

In this post, we will look at a Scala program to separate even and odd numbers in a List of Integers.

We can achieve this using “partition” function defined on List. partition function takes a predicate as parameter and separates the list values into two groups i.e., elements that are satisfying the predicates and the elements that are not.

Let’s look at the program:

Output:

Happy learning.

Please leave a reply in case of any queries.

Leave a Reply

Your email address will not be published.