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.
我有整数列表。
List(List(1, 1, 1, 1), List(2, 1, 1), List(2, 2))
我想从列表中获取最小大小的列表,即 List(2,2)。在 Scala 中推荐的方法是什么?
几乎与今天提出的另一个问题重复:
val xs = List(List(1, 1, 1, 1), List(2, 1, 1), List(2, 2)) xs.minBy(list => list.length) // res0: List[Int] = List(2, 2)