By using partition
method:
scala> List(1,2,3,4).partition(x => x % 2 == 0)
res0: (List[Int], List[Int]) = (List(2, 4),List(1, 3))
More Related Contents:
- How to store custom objects in Dataset?
- What is the difference between self-types and trait subclasses?
- Is the Scala 2.8 collections library a case of “the longest suicide note in history”? [closed]
- What are type lambdas in Scala and what are their benefits?
- How do I break out of a loop in Scala?
- Scala: Why mapValues produces a view and is there any stable alternatives?
- Scala @ operator
- Joining Spark dataframes on the key
- Scala’s “for comprehension” with futures
- How to set heap size for sbt?
- Scala Map implementation keeping entries in insertion order?
- Modify collection inside a Spark RDD foreach
- How to write unit tests in Spark 2.0+?
- Easy idiomatic way to define Ordering for a simple case class
- What is *so* wrong with case class inheritance?
- What are the relationships between Any, AnyVal, AnyRef, Object and how do they map when used in Java code?
- How to create SBT project with IntelliJ Idea?
- How to apply a function to a tuple?
- Spark: Transpose DataFrame Without Aggregating
- Advantages of F-bounded polymorphism over typeclass for return-current-type problem
- Why won’t the Scala compiler apply tail call optimization unless a method is final?
- Exploding nested Struct in Spark dataframe
- Why is parameter in contravariant position?
- How to run jar generated by package (possibly with other jars under lib)?
- Can multi-projects from GIT be used as SBT dependencies?
- Is there an equivalent to SuppressWarnings in Scala?
- Why isn’t Validation a Monad?
- Can I import from multiple packages all at once in Scala?
- How is this case class match pattern working?
- Is it possible to have tuple assignment to variables in Scala? [duplicate]