gremlin语言介绍四:predicate

gremlin语言介绍四:predicate,第1张

gremlin的predicate用于判断一个值是否满足一定条件,而不只是相等。还可以是大于,大于或等于,小于以及这些条件的组合。字符串类型还可以用来判断是否包含特定字符串,或以指定字符串开始或结束

gremlin支持的predicate有以下这些:

判断等于或不等于

数值类型比较

inside表示在两个值之间,不包含边界值

outside表示在两个值之外,不包含边界值

between也表示在两个值之间,但是包含边界值

within表示值是否是序列中的一个。举例如下:

字符串特定的predicate

多个predicate可以通过and()、or()、not()组合成复杂的判断逻辑,而且支持嵌套,例如:

您好,Whether we are

celebrating important occasions or just relaxing with friends, eating is

an important social pasttime. It is also an important part of our

culture.

这一句的结构是(让步状语从句+主句)

1)让步状语从句 = whether we are celebrating important occasions or just relaxing with friends

2)主句 = eating is an important social pasttime.

而在这个让步状语从句是由 whether 引导的,or 是并列连词,并列了两个让步状语从句,而两个让步状语从句的主语和助动词都是一样,第二个句子就被省略了。所以句子未并列之前是:

Whether we are celebrating important occasions, eating is an important social pasttime.

Whether we are just relaxing with friends, eating is an important social pasttime.

合并后为 Whether we are celebrating important occasions or (whether we are) just relaxing with friends, eating is an important social pasttime.

所以 or 这里的确可以看做是并列两个句子,而(连词)、(从句主语),谓语动词的(助动词)部分在第二句被省略了。

根据语法规则,当并列时(不论是 and,还是 or,或是 but),假如主语和(助动词)是雷同的,在并列的第二句是可以省略的。比如:

We are singing and dancing in the party.

= We are singing in the party. + We are dancing in the party.

= 用(and 并列)We are singing and (we are) dancing in the party.

We are either singing or dancing in the party.

= We are singing in the party. + We are dancing in the party.

= 用(either ... or ... 并列)We are either singing or (We are) dancing in the party.

We are not singing but dancing in the party.

= We are not singing in the party. + We are dancing in the party.

= 用(but 并列)We are not singing but (we are) dancing in the party.

还可以看得到地点状语(in the party)也被省略1个。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11661825.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-17
下一篇 2023-05-17

发表评论

登录后才能评论

评论列表(0条)

保存