是否有一种没有控制结构或运算符的编程语言?

发布于 2024-08-30 20:14:41 字数 828 浏览 5 评论 0原文

喜欢 Smalltalk 或 Lisp?

编辑

其中控制结构类似于:

     Java                 Python               
 if( condition ) {     if cond:           
     doSomething           doSomething     
 }                                         

Or

     Java                Python                  
 while( true )  {        while True:            
     print("Hello");        print "Hello"      
 }                                            

And 运算符

 Java, Python
 1 + 2  // + operator 
 2 * 5  // * op

在 Smalltalk 中(如果我是正确的)将是:

condition ifTrue:[
   doSomething
]

True whileTrue:[
   "Hello" print 
]
1 + 2 // + is a method of 1 and the parameter is 2 like 1.add(2) 
2 * 5 // same thing

Like Smalltalk or Lisp?

EDIT

Where control structures are like:

     Java                 Python               
 if( condition ) {     if cond:           
     doSomething           doSomething     
 }                                         

Or

     Java                Python                  
 while( true )  {        while True:            
     print("Hello");        print "Hello"      
 }                                            

And operators

 Java, Python
 1 + 2  // + operator 
 2 * 5  // * op

In Smalltalk ( if I'm correct ) that would be:

condition ifTrue:[
   doSomething
]

True whileTrue:[
   "Hello" print 
]
1 + 2 // + is a method of 1 and the parameter is 2 like 1.add(2) 
2 * 5 // same thing

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

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

发布评论

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

评论(18

风向决定发型 2024-09-06 20:14:41

你以前怎么从未听说过 lisp?

how come you've never heard of lisp before?

我乃一代侩神 2024-09-06 20:14:41

您的意思是没有特殊的语法来实现相同的目的?

许多语言都具有控制结构和运算符,它们“实际上”是某种形式的消息传递或可以重新定义的功能调用系统。大多数“纯”对象语言和纯函数语言都符合要求。但他们仍然会有你的“+”和某种形式的代码块——包括 SmallTalk!——所以你的问题有点误导。

You mean without special syntax for achieving the same?

Lots of languages have control structures and operators that are "really" some form of message passing or functional call system that can be redefined. Most "pure" object languages and pure functional languages fit the bill. But they are all still going to have your "+" and some form of code block--including SmallTalk!--so your question is a little misleading.

夜声 2024-09-06 20:14:41
  1. 程序集
  2. Befunge
  1. Assembly
  2. Befunge
原谅我要高飞 2024-09-06 20:14:41

Prolog*

*对于因尝试了解这项技术而导致的任何挫败感和/或头痛,我不承担任何责任,也不对由于上述情况而对您造成的任何损害负责包括但不限于损坏的键盘、穿孔的屏幕和/或办公桌上的头形凹痕。

Prolog*

*I cannot be held accountable for any frustration and/or headaches caused by trying to get your head around this technology, nor am I liable for any damages caused by you due to aforementioned conditions including, but not limited to, broken keyboard, punched-in screen and/or head-shaped dents in your desk.

美人骨 2024-09-06 20:14:41

纯 lambda 演算?这是整个语言的语法:

e ::= x | e1 e2 | \x . e

您拥有的只是变量、函数应用和函数创建。它的功率相当于图灵机。对于诸如

  • If-then-else
  • while-do
  • 递归之

类的构造和诸如

  • 布尔
  • 整数、
  • 记录
  • 列表、树和其他递归类型之

类的数据类型,有众所周知的编码(通常是“Church 编码”) 。 lambda 演算中的编码可能有很多有趣——我们的学生将在明年春天的本科语言课程中做到这一点。

Pure lambda calculus? Here's the grammar for the entire language:

e ::= x | e1 e2 | \x . e

All you have are variables, function application, and function creation. It's equivalent in power to a Turing machine. There are well-known codings (typically "Church encodings") for such constructs as

  • If-then-else
  • while-do
  • recursion

and such datatypes as

  • Booleans
  • integers
  • records
  • lists, trees, and other recursive types

Coding in lambda calculus can be a lot of fun—our students will do it in the undergraduate languages course next spring.

囍笑 2024-09-06 20:14:41

Forth 可能符合条件,具体取决于您所说的“无控制结构或运营商”的含义。 Forth 可能看起来有它们,但实际上它们都只是符号,并且“控制结构”和“运算符”可以由程序员定义(或重新定义)。

Forth may qualify, depending on exactly what you mean by "no control structures or operators". Forth may appear to have them, but really they are all just symbols, and the "control structures" and "operators" can be defined (or redefined) by the programmer.

倾城花音 2024-09-06 20:14:41

Logo 或更具体地说,海龟图形?我相信我们都记得,PEN UP、PEN DOWN、FORWARD 10 等等。

What about Logo or more specifically, Turtle Graphics? I'm sure we all remember that, PEN UP, PEN DOWN, FORWARD 10, etc.

陈独秀 2024-09-06 20:14:41

SMITH 编程语言:

http://esolangs.org/wiki/SMITH

http://catseye.tc/projects/smith/

它没有跳跃,并且是图灵完备的。几年前我还为这个坏男孩制作了一个 Haskell 解释器。

The SMITH programming language:

http://esolangs.org/wiki/SMITH

http://catseye.tc/projects/smith/

It has no jumps and is Turing complete. I've also made a Haskell interpreter for this bad boy a few years back.

乖乖兔^ω^ 2024-09-06 20:14:41

那么我将首先提到brain****

I'll be first to mention brain**** then.

像你 2024-09-06 20:14:41

在 Tcl 中,没有控制结构;只有命令,并且它们全部都可以重新定义。每最后一张。也没有运营商。好吧,除了 in 表达式,但这实际上只是导入的外来语法,不是语言本身的一部分。 (我们还可以导入完整的 CFortran 或其他任何语言。)

In Tcl, there's no control structures; there's just commands and they can all be redefined. Every last one. There's also no operators. Well, except for in expressions, but that's really just an imported foreign syntax that isn't part of the language itself. (We can also import full C or Fortran or just about anything else.)

安静 2024-09-06 20:14:41

FRACTRAN 怎么样?

FRACTRAN 是数学家 John Conway 发明的图灵完备的深奥编程语言。 FRACTRAN 程序是正分数的有序列表以及初始正整数输入n。该程序通过更新整数 (n) 来运行,如下所示:

  1. 对于列表中 nf 为整数的第一个分数 f,将 n 替换为 nf
  2. 重复此规则,直到列表中没有分数在乘以n时产生整数,然后停止。

当然,规则2中有一个隐含的控制结构。

How about FRACTRAN?

FRACTRAN is a Turing-complete esoteric programming language invented by the mathematician John Conway. A FRACTRAN program is an ordered list of positive fractions together with an initial positive integer input n. The program is run by updating the integer (n) as follows:

  1. for the first fraction f in the list for which nf is an integer, replace n by nf
  2. repeat this rule until no fraction in the list produces an integer when multiplied by n, then halt.

Of course there is an implicit control structure in rule 2.

哆兒滾 2024-09-06 20:14:41

D(在 DTrace 中使用)?

D (used in DTrace)?

始终不够爱げ你 2024-09-06 20:14:41

APT -(自动编程工具)广泛用于 NC 机床编程。
该语言也没有 IO 功能。

APT - (Automatic Programmed Tool) used extensively for programming NC machine tools.
The language also has no IO capabilities.

勿挽旧人 2024-09-06 20:14:41

XSLT(或有人说 XSL)具有诸如 iffor 之类的控制结构,但您通常应该避免它们,并通过编写具有正确的特异性级别的规则来处理所有事情。因此,控制结构就在那里,但由翻译引擎所做的默认操作暗示:应用潜在递归规则。

Forif (以及其他一些)确实存在,但在很多情况下您可以而且应该解决它们。

XSLT (or XSL, some say) has control structures like if and for, but you should generally avoid them and deal with everything by writing rules with the correct level of specificity. So the control structures are there, but are implied by the default thing the translation engine does: apply potentially-recursive rules.

For and if (and some others) do exist, but in many many situations you can and should work around them.

匿名的好友 2024-09-06 20:14:41

每当怎么样?

程序由“待办事项列表”组成——一系列以随机顺序执行的语句。每个语句都可以包含一个先决条件,如果未满足该先决条件,则会导致该语句被推迟到某个(随机)稍后的时间。

How about Whenever?

Programs consist of "to-do list" - a series of statements which are executed in random order. Each statement can contain a prerequisite, which if not fulfilled causes the statement to be deferred until some (random) later time.

一个人练习一个人 2024-09-06 20:14:41

我对这个概念并不完全清楚,但我认为 PostScript 符合标准,尽管它调用其所有函数运算符(LISP 调用其所有运算符函数的方式)。

I'm not entirely clear on the concept, but I think PostScript meets the criteria, although it calls all of its functions operators (the way LISP calls all of its operators functions).

江挽川 2024-09-06 20:14:41

Makefile 语法似乎没有任何运算符或控制结构。我想说它是一种编程语言,但它不是图灵完备的(无论如何都没有对 POSIX 标准的扩展)

Makefile syntax doesn't seem to have any operators or control structures. I'd say it's a programming language but it isn't Turing Complete (without extensions to the POSIX standard anyway)

转角预定愛 2024-09-06 20:14:41

那么...您正在寻找一种超级简单的语言吗? 批量编程怎么样?如果您有任何版本的 Windows,则可以使用批处理编译器。它也比您想象的更有用,因为您可以执行基本的文件功能(复制、重命名、创建目录、删除文件等)

http://www.csulb.edu/~murdock/dosindex.html

示例

  1. 打开记事本并在 Windows 机器上创建一个 .Bat 文件。
  2. 使用记事本打开 .Bat 文件
  3. 在第一行中,键入“echo off”
  4. 在第二行中,键入“echo hello world”
  5. 在第三行中,键入“pause”
  6. 保存并运行该文件。

如果您正在寻找学习一些非常基本编程的方法,这是一个很好的起点。 (请小心使用“删除”和“格式化”命令。不要尝试这些命令。)

So... you're looking for a super-simple language? How about Batch programming? If you have any version of Windows, then you have access to a Batch compiler. It's also more useful than you'd think, since you can carry out basic file functions (copy, rename, make directory, delete file, etc.)

http://www.csulb.edu/~murdock/dosindex.html

Example

  1. Open notepad and make a .Bat file on your Windows box.
  2. Open the .Bat file with notepad
  3. In the first line, type "echo off"
  4. In the second line, type "echo hello world"
  5. In the third line, type "pause"
  6. Save and run the file.

If you're looking for a way to learn some very basic programming, this is a good way to start. (Just be careful with the Delete and Format commands. Don't experiment with those.)

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