TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Lisp in 1,200 lines of Dart

4 点作者 suzuki大约 10 年前

1 comment

suzuki大约 10 年前
This is a Lisp interpreter with macros, backquotation and tail-call optimization. It is written in 1,200 lines of a script in Dart 1.9.<p><pre><code> $ curl -R -O http:&#x2F;&#x2F;www.oki-osk.jp&#x2F;esc&#x2F;dart&#x2F;lisp&#x2F;lisp-27-04-20.tar.bz2 $ tar xf lisp-27-04-20.tar.bz2 $ cd lisp-27-04-20 $ wc lisp.dart 1200 4696 36500 lisp.dart $ dart lisp.dart &gt; (defmacro aif (test then &amp;rest else) `(let ((it ,test)) (if it ,then ,@else))) aif &gt; (defun find (x list) (aif (member x list) (car it))) find &gt; (find 10 &#x27;(1 2 3)) nil &gt; (find 2 &#x27;(1 2 3)) 2 &gt; find #&lt;closure:2:nil:((#&lt;lambda:1:((cond (#0:0:it (car #0:0:it))))&gt; (member #0:0:x #0:1:list)))&gt;</code></pre>