Logo 编程语言
Logo Programming

原始链接: https://el.media.mit.edu/logo-foundation/what_is_logo/logo_programming.html

Logo 程序是由一系列小型模块化过程组成的。通过使用 `to` 命令后跟一个名称,并以 `end` 结束,用户可以定义与内置原语功能完全相同的新指令。这些过程充当了构建块;简单的任务(如绘制正方形)可以嵌套在更复杂的序列中(如创作一朵花或整个花园)。 Logo 的一个主要优势是其可扩展性。编程涉及扩展语言的词汇量,即基于它已理解的词汇来教授它新词。一旦定义完成,用户创建的过程与语言的原始命令便没有区别,从而实现了自定义逻辑的无缝集成。这种分层方法使用户能够通过易于管理的渐进步骤构建复杂的项目,这反映了人类学习和构建语言的自然方式。

抱歉。
相关文章

原文

Logo programs are usually collections of small procedures. Generally, procedures are defined by writing them in a text editor. The special word to is followed by the name of the procedure. Subsequent lines form the procedure definition. The word end signals that you're finished.

In our turtle graphics example we defined a procedure to draw a square

to square
repeat 4 [forward 50 right 90]
end

and used it as a subprocedure of another procedure

to flower
repeat 36 [right 10 square]
end

Similarly, flower could be a building block of something larger

to garden
repeat 25 [set-random-position flower]
end

No, set-random-position is not a primitive, but random is and so is setposition (or setpos or setxy). Or you could write set-random-position using forward and right with random.

Once a Logo procedure is defined it works like the Logo primitives. In fact, when you look at Logo programs there's no way of knowing which words are primitives and which are user-defined unless you know that particular Logo implementation. In our language sample we used the procedure pick to randomly select an item from a list, for example in the procedure who.

to who
output pick [Sandy Dale Dana Chris]
end

In some versions of Logo pick is a primitive while in others you have to write it yourself. Who would look and work the same way in either case.

Logo allows you to build up complex projects in small steps. Programming in Logo is done by adding to its vocabulary, teaching it new words in terms of words it already knows. In this way it's similar to the way people learn spoken language.

联系我们 contact @ memedata.com