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
Post a Comment