Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何将列表L(或任何其他集合)拆分为 2 个列表,以便第一个包含 80%,L第二个包含其余部分?
L
val (first80pct, rest) = L.splitAt(L.size * 4 / 5)
在没有确定长度的集合(例如流)上使用它时要小心。