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 -

c++ - Issues with OpenGL referencing when compiling in Ubuntu terminal -

Using Angularjs $http in browser console -