Scala, find largest list in a list
假设 val a = List[List[int]]:
在 Scala 中查找包含最多元素的列表的最简洁方法是什么?
尝试 .maxBy 或 .maxByOption
之一
1 2 3
|
List(List(0)).maxBy(_.size) // List(0)
List(List(0)).maxByOption(_.size) // Some(List(0))
List.empty[List[Int]].maxByOption(_.size) // None
|
1
|
List(List(1), List(2, 3)).maxBy(_.size)
|
来源:https://www.codenong.com/61913523/
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_10756.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57