你不假思索第一反应回答: "Either A or B" 翻译成开发中的逻辑关系是?

2017-01-26 18:27:57 +08:00
 KentY

今天被同事问到,然后,我答错了... :-( 被告知答案后..服气.

8904 次点击
所在节点    程序员
57 条回复
xupefei
2017-01-27 00:07:59 +08:00
@edimetia3d
```
Either this apple or that apple is bad == Both apples are bad.
```
Are you serious?
lyz1990
2017-01-27 00:42:01 +08:00
data Either a b = Left a | Right b
scnace
2017-01-27 02:23:43 +08:00
所以直译应该是 不是 A 就是 B 吗?这样好像就排除掉 Both True 的 case 了(突然觉得中文博大精深啊!
ynyounuo
2017-01-27 02:32:00 +08:00
@ZE3kr 有些 formal logic language 是以 \oplus 作为 XOR 的逻辑符号的嘛
RqPS6rhmP3Nyn3Tm
2017-01-27 03:09:30 +08:00
A V B
/or 符号打不出来,用 V 代替。离散数学基础啊兄弟们
RqPS6rhmP3Nyn3Tm
2017-01-27 03:10:50 +08:00
如果是 exclusive or 一般都会注明的,默认就是||我觉得没问题
ynyounuo
2017-01-27 03:49:09 +08:00
@BXIA \lor 或者 \vee 可以打 ∨ (U+2228)
icylogic
2017-01-27 04:08:59 +08:00
stack exchange 上的两个答案

>It isn't always actually used with full precision, though, so, as usual, context has to be taken into account. If somebody says, "select either A or B", for example, they definitely mean that you should not select both. If they say "if either A or B is true", though, they probably mean a non-exclusive OR, and the condition is still true if both A and B are true.

>Usually, the inclusive sense is used in mathematics and the exclusive sense in everyday life. In any case, further specification or context will remove any doubt.

所以如果是 choose either A or B 这样那肯定就是 xor 了,但其他情况看语境也可能与 or 同义


还有 math.toronto.edu 给了同样的解释:

>In every day language we use the phrase "either A or B" to mean that one of the two options holds, but not both.For example, when most people say something like ``You can have either a hot dog or hamburger," they usually aren't offering you both. The use of ``either/or" in everyday English is usually divisive, and meant to imply there are only two options: A or B, but not both A and B. (The use of "or" in this way is sometimes referred to as "exclusive or.")

>However, the use of "either A or B" in mathematics allows the option that both A and B hold. (The use of "or" in this way is sometimes referred to as "inclusive or.") For example, in mathematics, the statement "If x is a real number, then either x≤0 or x≥0" allows the possibility that x satisfies both x≤0, as well as x≥0 (which is true of the real number 0).
icylogic
2017-01-27 04:12:14 +08:00
特别是 "either A or B is true" 这种判断逻辑的情况,很有可能应该等同于 or 。

https://en.wikipedia.org/wiki/Logical_disjunction#Natural_language

**On the other hand, "Her grades are so good that she's either very bright or studies hard" does not exclude the possibility of both.**
eyp82
2017-01-27 04:19:24 +08:00
我的第一反应就是: A or B ... (Python)
tt7
2017-01-27 04:30:01 +08:00
assert a or b
Balthild
2017-01-27 08:27:23 +08:00
bool either(bool A, bool B);

either(A, B);
czk1997
2017-01-27 12:25:46 +08:00
根据剑桥的解释:
used to refer to a situation in which there is a choice between two different plans of action, but both together are not possible:
It's an either-or situation - we can buy a new car this year or we can go on holiday, but we can't do both.
就是可以其中一个为真,结果为真,但是不能都为真。
halden
2017-01-27 13:38:46 +08:00
凭我的经验英文中的 either 不带 both ,老美会说 either A or B, or both 。所以应该是 (A && !B) || (!A && B)
thekll
2017-01-27 22:43:27 +08:00
!A != !B
precisi0nux
2017-01-28 10:16:53 +08:00
$a or $b|Or|TRUE if either $a or $b is TRUE.
$a xor $b|Xor|TRUE if either $a or $b is TRUE, but not both.

世界上最好的语言如是说。
nozama
2017-01-28 23:30:22 +08:00
xor

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/337049

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX