草庐IT

predicates

全部标签

c# - 为什么用 Func<T,bool> 而不是 Predicate<T>?

这只是一个好奇的问题,我想知道是否有人有好的答案:在.NETFramework类库中,我们有以下两种方法:publicstaticIQueryableWhere(thisIQueryablesource,Expression>predicate)publicstaticIEnumerableWhere(thisIEnumerablesource,Funcpredicate)他们为什么使用Func而不是Predicate?好像是Predicate仅由List使用和Array,而Func几乎所有Queryable都使用和Enumerable方法和扩展方法……这是怎么回事?

c# - Func vs. Action vs. Predicate

这个问题在这里已经有了答案:Delegates:Predicatevs.Actionvs.Func(10个答案)关闭8年前。通过真实的例子和它们的使用,有人可以帮助我理解:我们什么时候需要Func委托(delegate)?我们什么时候需要Action委托(delegate)?我们什么时候需要Predicate委托(delegate)?

linux - 找到 : invalid predicate when using -newermt

我正在使用查找命令在特定时间之间获取文件并使用以下命令将其压缩,find/lag/cnn-max-depth3-newermt"2013-12-1900:00"-o-typef-newermt"2013-12-1600:00"-print0|xargs-0taracfout.tar.gz但是当我运行这个命令时,我得到:find:invalidpredicate`-newermt'。问题是什么?以及我该如何解决这个问题。更新:我实际上想做的是,路径是(使用ls-lrt/lag/cnn/*/*):/lag/cnn/Example1/one/a.tar.gz/lag/cnn/Example1

javascript - 等价于 LINQ 的 Enumerable.First(predicate)

在C#中,我们有Enumerable.First(predicate).鉴于此JavaScript代码:functionprocess(){varfirstMatch=['a','b','c'].filter(function(e){returnapplyConditions(e);}).shift();if(!firstMatch){return;}//dosomethingelse}functionapplyConditions(element){varmin=97;varmax=122;varrandom=Math.floor(Math.random()*(max-min+1)+

ruby - MiniTest中的assert_predicate有什么用?

我无法理解assert_predicate在MiniTest中的用途。它与assert_equal?有什么不同?人们什么时候想使用这个断言?我遇到过很多次,但并没有真正理解它的确切含义。 最佳答案 assert_equal检查期望值和实际值是否相等:assert_equal"Bender",robot.nameassert_predicate调用目标对象上的命名方法,如果结果为真则通过:assert_predicaterobot,:bender?您可以像这样轻松地编写此测试:assertrobot.bender?但是assert_p

ruby-on-rails - 从 Meta_search 升级到 Ransack 时出现 "No valid predicate"错误?

我有一个ActiveRecord模型,其方法定义如下:defstateifdeleted?:deletedelse:expiredendend“search_method”在模型中定义为:search_method:state在View中:=form.select:state,{:expired=>'Expired',:deleted=>'Deleted'}.invert,:include_blank=>'All'对于Meta_search,此方法运行良好。但是当我用Ransack替换gem时,我在示例Controller中得到:ArgumentError没有有效的状态谓词。我正在遵循

【Kotlin】函数式编程 ② ( 过滤函数 | predicate 谓词函数 | filter 过滤函数 | 合并函数 | zip 函数 | folder 函数 | 函数式编程意义 )

文章目录一、过滤函数二、filter函数原型三、filter过滤函数代码示例1、filter函数简单示例2、filter过滤函数与flatMap变换函数组合使用示例3、filter过滤函数与map变换函数组合使用示例四、合并函数1、zip合并函数2、folder合并函数五、函数式编程意义函数式编程的三种函数类别:变换Transform过滤Filter合并Combine在上一篇博客函数式编程①中讲解了变换函数map函数与flatMap函数,本篇博客中着重讲解过滤函数和合并函数;一、过滤函数过滤函数是函数式编程中的函数类型,一般该类型函数接收一个Predicate谓词函数作为参数;该谓词函数参数是

【Kotlin】函数式编程 ② ( 过滤函数 | predicate 谓词函数 | filter 过滤函数 | 合并函数 | zip 函数 | folder 函数 | 函数式编程意义 )

文章目录一、过滤函数二、filter函数原型三、filter过滤函数代码示例1、filter函数简单示例2、filter过滤函数与flatMap变换函数组合使用示例3、filter过滤函数与map变换函数组合使用示例四、合并函数1、zip合并函数2、folder合并函数五、函数式编程意义函数式编程的三种函数类别:变换Transform过滤Filter合并Combine在上一篇博客函数式编程①中讲解了变换函数map函数与flatMap函数,本篇博客中着重讲解过滤函数和合并函数;一、过滤函数过滤函数是函数式编程中的函数类型,一般该类型函数接收一个Predicate谓词函数作为参数;该谓词函数参数是

SpringCloud之Gateway网关路由转发route、断言predicates

官方文档:https://docs.spring.io/spring-cloud-gateway/docs/current/reference/html/1、gateway-ha提供服务4.0.0com.yzmspringcloud0.0.1-SNAPSHOT../pom.xmlgateway-ha0.0.1-SNAPSHOTjargateway-haDemoprojectforSpringBootorg.springframework.bootspring-boot-starter-weborg.springframework.cloudspring-cloud-starter-netfli

SpringCloud之Gateway网关路由转发route、断言predicates

官方文档:https://docs.spring.io/spring-cloud-gateway/docs/current/reference/html/1、gateway-ha提供服务4.0.0com.yzmspringcloud0.0.1-SNAPSHOT../pom.xmlgateway-ha0.0.1-SNAPSHOTjargateway-haDemoprojectforSpringBootorg.springframework.bootspring-boot-starter-weborg.springframework.cloudspring-cloud-starter-netfli