寻求条件表达 [英] conditional expression sought

查看:71
本文介绍了寻求条件表达的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果bool(B_i)== True为1< = i< = n且j为最小i,则bool(A_j)== True,

则评估(A_1和B_1) )或...或(A_n和B_n)返回B_j而不评估任何其他B_i的
。这是一种非常有用的表达方式,即使有一个我用

bool(B_i)== False,我也希望能够使用类似的东西。我唯一能想到的就是((A_1和[B_1])

或......或(A_n和[B_n]))[0],我不可能对此明显感到满意

的原因。有人知道表达这个的好方法吗?任何帮助都会很多

欣赏。


和平

If bool(B_i)==True for 1<=i<=n and j is the smallest i with bool(A_j)==True,
then the evaluation of (A_1 and B_1) or ... or (A_n and B_n) returns B_j without
evaluating any other B_i. This is such a useful mode of expression that I would
like to be able to use something similar even when there is an i with
bool(B_i)==False. The only thing I can think of by myself is ( (A_1 and [B_1])
or ... or (A_n and [B_n]) )[0], and I can''t be satisfied with that for obvious
reasons. Does anybody know a good way to express this? Any help will be mucho
appreciado.

Peace

推荐答案

自是真还是假

还可以评估为1和0

你可以使用二元运算符

|和&

for or和and
since True and False
can also evaluate as 1 and 0
you can use the binary operators
| and &
for or and and respectively
F类:
.... a = 5

.... def b(个体经营):

.... self.a = 4

....返回True

.... def a(self):

.... self.a = 1

....返回False

.... g = F()
ga()& g.b()
False g.a
class F: .... a = 5
.... def b(self):
.... self.a = 4
.... return True
.... def a(self):
.... self.a = 1
.... return False
.... g = F()
g.a() & g.b() False g.a




" Elaine Jackson" < EL *************** @ home.com>在消息中写道

news:pRbSb.330334

4
"Elaine Jackson" <el***************@home.com> wrote in message
news:pRbSb.330334


ts4.37644@pd7tw3no ...如果bool(B_i)== True为1< = i< = n和j是最小的i,带有
bool(A_j)== True,然后评估(A_1和B_1)或......或(A_n和B_n)返回B_j
而不评估任何其他B_i 。这是一种非常有用的表达方式,即使有一个带有
bool(B_i)== False的i,我也希望能够使用类似的东西。我唯一能想到的就是((A_1和
[B_1])或......或(A_n和[B_n]))[0],我不能满足于此
显而易见的原因。有人知道表达这个的好方法吗?任何帮助将是
mucho appreciado。

和平
ts4.37644@pd7tw3no... If bool(B_i)==True for 1<=i<=n and j is the smallest i with bool(A_j)==True, then the evaluation of (A_1 and B_1) or ... or (A_n and B_n) returns B_j without evaluating any other B_i. This is such a useful mode of expression that I would like to be able to use something similar even when there is an i with
bool(B_i)==False. The only thing I can think of by myself is ( (A_1 and [B_1]) or ... or (A_n and [B_n]) )[0], and I can''t be satisfied with that for obvious reasons. Does anybody know a good way to express this? Any help will be mucho appreciado.

Peace



Elaine Jackson写道:
Elaine Jackson wrote:
如果bool(B_i)== True为1< = i< = n而j是最小的i与bool(A_j)== True,
则评估(A_1和B_1)或......或(A_n和B_n)返回B_j而不评估任何其他B_i。这是一种非常有用的表达方式,即使有一个带有
bool(B_i)== False的i,我也希望能够使用类似的东西。我唯一能想到的就是((A_1和[B_1])
或......或(A_n和[B_n]))[0],我不能满足于此显而易见的原因。有人知道表达这个的好方法吗?任何帮助都会很有意思。
If bool(B_i)==True for 1<=i<=n and j is the smallest i with bool(A_j)==True,
then the evaluation of (A_1 and B_1) or ... or (A_n and B_n) returns B_j without
evaluating any other B_i. This is such a useful mode of expression that I would
like to be able to use something similar even when there is an i with
bool(B_i)==False. The only thing I can think of by myself is ( (A_1 and [B_1])
or ... or (A_n and [B_n]) )[0], and I can''t be satisfied with that for obvious
reasons. Does anybody know a good way to express this? Any help will be mucho
appreciado.



为什么不写一个单元测试来演示你想要的行为呢?

那么它很可能对于某个人来说,显而易见的是你的问题和

可能的解决方案是什么。


干杯,


// m


Why not write a unit test that demonstrates the behavior you want?
It''ll then likely be obvious to someone both what your problem is and
what a likely solution is.

Cheers,

// m


这篇关于寻求条件表达的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆