How to split List in Scala? -


how split list l (or other collection) 2 lists, first 1 contains 80% of l , second 1 contains rest?

val (first80pct, rest) = l.splitat(l.size * 4 / 5) 

you want careful of using on collection without definite length (eg. streams).


Comments

Popular posts from this blog

c++ - Linked List error when inserting for the last time -

java - activate/deactivate sonar maven plugin by profile? -

java - What is the difference between String. and String.this. ? -