How to split a sequence into two pieces by predicate?

后端 未结 6 939
孤城傲影
孤城傲影 2020-12-02 11:35

How do I split a sequence into two lists by a predicate?

Alternative: I can use filter and filterNot, or write my own method, but isn\'t th

6条回答
  •  时光取名叫无心
    2020-12-02 12:17

    You might want to take a look at scalex.org - it allows you to search the scala standard library for functions by their signature. For example, type the following:

    List[A] => (A => Boolean) => (List[A], List[A])
    

    You would see partition.

提交回复
热议问题