任何语言都使用“=/=”吗?用于表示不等于运算符

发布于 2024-09-06 08:59:01 字数 129 浏览 4 评论 0原文

  1. 是否有任何编程语言使用 =/= 来表示不等于?
  2. 扫描仪识别这样的操作员是否存在词汇上的困难?还是历史上确实如此?

[注意:这不是家庭作业问题。我只是好奇。]

  1. Does any programming language use =/= for not-equal?
  2. Are there any lexical difficulties for scanners to recognize such an operator? Or was it the case historically?

[Note: this is NOT a homework question. I'm just curious.]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

日记撕了你也走了 2024-09-13 08:59:01

Erlang 用它来表示完全不等于

一般来说,扫描仪识别这样的令牌应该不会有任何困难(通过示例证明:Erlang;-)

Erlang uses it to denote exactly not equal to.

Also generally there shouldn't be any difficulties for scanners to recognize such a token (proof by example: Erlang ;-)

已下线请稍等 2024-09-13 08:59:01

在 Erlang =/= 中,正如 Bytecode Ninja 所说 的意思是“完全不等于”。 Erlang 的表示法深受 Prolog 的影响,因此 Prolog 也使用该运算符也就不足为奇了。有几种语言使得定义运算符变得微不足道。哈斯克尔就是这样的一个。 =/= 没有在 Haskell 标准中定义,但是定义它是微不足道的:

(=/=) x y = ....

这可以在类似函数调用的语法中使用:

(=/=) 5 6

或者作为内联运算符:

5 =/= 6

语义将取决于当然是实施。

我认为 Common Lisp weenies 用户也可以编写某种使用该序列的阅读器宏,但我并不肯定。

In Erlang =/=, as noted by Bytecode Ninja means "exactly not equal to". The notation of Erlang is strongly influenced by Prolog so it should come as no surprise that Prolog uses that operator too. There are several languages which make defining operators trivial. Haskell would be one such. =/= isn't defined in the Haskell standard, but defining it would be trivial:

(=/=) x y = ....

This could then be used in function call-like syntax:

(=/=) 5 6

Or as an inline operator:

5 =/= 6

The semantics would depend on the implementation, of course.

I think that Common Lisp weenies users could write some kind of reader macro that used that sequence too, but I'm not positive.

递刀给你 2024-09-13 08:59:01
  1. 不是主流之一。然而,人们可以轻松地创建这样一种语言。
    • (正如其他人提到的,Erlang 和其他一些语言已经拥有它)
  2. 不。除非你有一种非常奇怪的语言,否则这个运算符在词法分析方面没有什么特别的。

顺便说一下,Java 有:

  • > (大于)
  • >> (有符号右移)
  • >>= (有符号右移复合赋值)
  • >>> (无符号右移)
  • >>>= (无符号右移复合赋值)
  • >< /code> (关闭泛型类型参数,可嵌套)
    • >>>>>>>>、...

以及他们都工作得很好。

相关问题

  1. Not one of the mainstream ones. One could easily create such a language, however.
    • (As others have mentioned, Erlang and a few other languages do have it already)
  2. Nope. Unless you have a really weird language, there's nothing special about this operator in terms of lexical analysis.

By the way, Java has:

  • > (greater than)
  • >> (signed right shift)
  • >>= (signed right shift compound assignment)
  • >>> (unsigned right shift)
  • >>>= (unsigned right shift compound assignment)
  • > (closing generic type parameter, nestable)
    • >>, >>>, >>>>, ...

and they all work just fine.

Related question

影子是时光的心 2024-09-13 08:59:01

是的,Erlang 使用此符号作为一个符号其表示形式为“不等于”。

Erlang 是一种对并发有强大支持的语言,最初在爱立信内部设计并使用为电话交换机编写软件,但现在在国外广受欢迎。

Yes, Erlang uses this symbol as one of its representations for "not equal".

Erlang is a language with strong support for concurrency, originally designed within Ericsson and used for writing software for telephone exchanges, but now gaining significant popularity outside.

旧竹 2024-09-13 08:59:01

您可能需要查看Fortress 介绍性幻灯片。 Fortess 使用 =/= 来检查不等式。我想你会寻找语言的可读性。如果是这样的话,我可以说 Fortess 代码可以被渲染成看起来非常整洁的 TeX。

Project Fortress Old Site(已移至 java.net)

You may want to check out Fortress Introductory Slides. Fortess uses =/= for checking inequality. I suppose you look for readability in languages. If that's the case then I can tell that Fortess code can be rendered into very neat looking TeX.

Project Fortress Old Site (moved to java.net)

半仙 2024-09-13 08:59:01
  1. 据我所知,没有
  2. +=?? 等任何其他运算符难多少。

但是,键入这样的运算符非常麻烦。甚至 != 也会更简单。

  1. None that I know of
  2. Not much harder than any other operator like +=, ??, etc.

However, it's very cumbersome to type such an operator. Even != will be simpler.

醉态萌生 2024-09-13 08:59:01

Google 代码搜索 for =/= 没有出现任何明显的结果,所以我不会说什么主流。

您想要的任何运算符都不会有任何问题,计算机只会查找 =/= 而不是 !=<> 或您的语言使用的任何内容。

有一些非常奇怪的语言,例如 BrainFuck 语言 (link)

++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.    <<+++++++++++++++.>.+++.——.——–.>+.>.

这是“Hello World”的代码。

A google code search for =/= doesn't turn up anything obvious, so I would say nothing mainstream.

There wouldn't be any issues with any operator you want, the computer would simply look for =/= instead of != or <> or whatever your language uses.

There are some really weird languages out there like BrainFuck language (link)

++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.    <<+++++++++++++++.>.+++.——.——–.>+.>.

That is code for "Hello World".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文