English 中文(简体)
具有短暂平等逻辑特征的方案拟订语言
原标题:Programming languages that feature shorthand equality logic, for comparing one variable to multiple
  • 时间:2011-08-22 09:35:13
  •  标签:
  • equality

我很想知道是否有“相对平等”的方案拟订语言(我只是把这一术语说上了,但并不肯定如何描述它)。

因此,不是正常的:

如果(X=1 ±X=) 2)

一种短暂的平等检查,如:?

如果(X=1) 2)

我的理解是,有许多人赞成和反对这种建筑。 而且,我可以发挥类似的作用,但我很想知道,是否有语言使你能够在盒子之外做事。


EDIT

感谢迈克尔帮助我澄清事情,就像沙里一样。

我尝试并作更好的解释,因为从我前面的问题来看,这并没有很好地解释。

不是在收集中检查某件事,就是在背景中进行收集。

我不禁要问,是否有方案规划语言,只有一度界定左手变量,才能自动为你们创造左边和正确的东西。

因此:

if (X == 1 || 2 || 3)

实际创造

如果有(X=1 ±X=2 ±X======= 3)

我认识到,这种假乐的辛迪加非常有用,而创建这种收集就是这样做的好办法。 但想知道,它是否存在于任何地方。

最佳回答

我不了解与这种辛迪加有任何关系,但与为固定成员进行测试密切相关,许多语文确实包括,作为语言建筑或图书馆。

例如,认为这比喻:

x = 1
if x in {1, 2}:
    #do something

这部建筑在Aval 2.7+,在那里有 literal字。 早先的Sharma版本将构造如下:

x = 1
if x in set([1, 2]):
    #do something

除语气差异外,上述定型办法也有所不同,因为所有可能的价值都得到了热切评价。 例如,你可以:

x = 1
if x in {1, 2/0}:
    #do something

你们一分,就错了。

问题回答

页: 1

case $x in one | 2 | thr33 | f0re) echo less than six;; esac  # spot logic error




相关问题
What s the right way to implement equality in ruby

For a simple struct-like class: class Tiger attr_accessor :name, :num_stripes end what is the correct way to implement equality correctly, to ensure that ==, ===, eql?, etc work, and so that ...

Basic Java question: String equality

public class A { static String s1 = "I am A"; public static void main(String[] args) { String s2 = "I am A"; System.out.println(s1 == s2); } } Above program outputs "...

Test for equality to the default value

The following doesn t compile: public void MyMethod<T>(T value) { if (value == default(T)) { // do stuff } } Error: Operator == cannot be applied to operands of type T ...

Best way to write an or is equal statement

Hello $mostamazingforumforfastanswersever. I have a quick silly question; what is the best way to write this : if ($curpageurl == "www.mysite.com/this" || "www.mysite.com/this/") { echo this is ...

Python: Can you make this __eq__ easy to understand?

I have another question for you. I have a python class with a list metainfo . This list contains variable names that my class might contain. I wrote a __eq__ method that returns True if the both ...

Equality Test for Derived Classes in C++ [duplicate]

Possible Duplicate: What’s the right way to overload operator== for a class hierarchy? In C++, how can derived classes override the base class equality test in a meaningful way? For ...

热门标签