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

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

python - TypeError: can only concatenate tuple (not "float") to tuple -

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