Mic*_*ael 1 collections scala partitioning list
如何将列表L(或任何其他集合)拆分为2个列表,以便第一个包含80%,L第二个包含其余列表?
L
Sha*_*nds 6
val (first80pct, rest) = L.splitAt(L.size * 4 / 5)
您可能需要小心在没有确定长度的集合上使用它(例如,流).
归档时间:
12 年,9 月 前
查看次数:
484 次
最近记录: