Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
检查集合中的所有项是否与Scala中的谓词匹配_Scala_Predicate - Fatal编程技术网

检查集合中的所有项是否与Scala中的谓词匹配

检查集合中的所有项是否与Scala中的谓词匹配,scala,predicate,Scala,Predicate,测试集合的所有项是否匹配谓词的最惯用方法是什么 有任何项吗?此项有内置功能: List(1,2,3,4).forall(x => x < 5) res0: Boolean = true List(1,2,3,4).exists(x => x > 3) res1: Boolean = true

测试集合的所有项是否匹配谓词的最惯用方法是什么


有任何项吗?

此项有内置功能:

List(1,2,3,4).forall(x => x < 5)
res0: Boolean = true
List(1,2,3,4).exists(x => x > 3)
res1: Boolean = true