最小的 LISP?

发布于 2024-10-10 08:18:37 字数 486 浏览 2 评论 0原文

可能的重复:
有多少构建 LISP 机器需要原语吗?十个、七个还是五个?

我很好奇。可以在其上构建所有其他功能的最小 LISP 是什么?忽略效率——这个问题仅仅来自于一个优雅的地方。

如果你在一个外星球上醒来,并被指示构建一个最小的 LISP,然后你可以在其上构建你喜欢的任何功能,你会包括什么?

编辑:澄清。我在这里的目的不是引发一场辩论,而是我正在考虑实现一个最小的 LISP,我想了解我可以做到最小化,同时仍然允许我实现的语言是图灵完整的,等等。如果这结果是有争议的,我我确信我会从观察争议中学到我想学到的东西。 :)。谢谢!

Possible Duplicate:
How many primitives does it take to build a LISP machine? Ten, seven or five?

I am curious. What is the most minimal LISP, upon which all further features could be built? Ignore efficiency -- the question comes simply from a place of elegance.

If you awoke on an alien planet and were instructed to build the most minimal LISP that you could later build upon to implement any feature you liked, what would you include?

Edit: Clarification. My intent here is not to start a debate, rather I am considering implementing a minimal LISP and I want to understand how minimal I can go while still allowing the language I implement to be Turing complete, etc. If this turns out to be controversial I am sure I will learn what I wanted to learn from observing the controversy. :). Thanks!

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

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

发布评论

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

评论(2

梦中楼上月下 2024-10-17 08:18:37

Paul Graham 提供,这里是 John McCarthy 原始 LISP 的 Common Lisp 实现

它假设 quote, atom, eqconscarcdrcond,并定义 null追加列表配对assocevalevconevlis

Courtesy of Paul Graham, here's a Common Lisp implementation of John McCarthy's original LISP:

It assumes quote, atom, eq, cons, car, cdr, and cond, and defines null, and, not, append, list, pair, assoc, eval, evcon and evlis.

栩栩如生 2024-10-17 08:18:37

Peter Norvig 用 90 行 Python 实现了一个 LISP 解释器,他的后续文章详细讨论了您所问的问题。非常值得一读,恕我直言。

http://norvig.com/lispy.html

我有一种感觉,他的“测序”很特别如果只有函数调用可以采用任意数量的参数,则可以删除表单。

(defun last (lst)
  (if (cdr lst) 
      (last (cdr lst))
      (car lst)))

(defun begin (:rest y) (last y))

但这会使函数应用变得复杂。

Peter Norvig implemented a LISP interpreter in 90 lines of Python, and his subsequent article discusses in detail what you're asking. Well worth the read, IMHO.

http://norvig.com/lispy.html

I've got a feeling that his "sequencing" special form could be dropped if only function calls could take an arbitrary number of parameters.

(defun last (lst)
  (if (cdr lst) 
      (last (cdr lst))
      (car lst)))

(defun begin (:rest y) (last y))

But this would complicate function application.

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