Reputation: 42100
How to split a list L
(or any other collection) into 2 lists, so that the first one contains 80% of L
and the second one contains the rest?
Upvotes: 1
Views: 829
Reputation: 15074
val (first80pct, rest) = L.splitAt(L.size * 4 / 5)
You would want to be careful of using this on a collection without a definite length (eg. streams).
Upvotes: 6