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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Show HN: Scheme with first-class call/cc in 700 lines of Go code

1 点作者 suzuki大约 6 年前

1 comment

suzuki大约 6 年前
This is a small interpreter of a subset of Scheme. It implements the same language as <a href="https:&#x2F;&#x2F;github.com&#x2F;nukata&#x2F;little-scheme-in-python" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nukata&#x2F;little-scheme-in-python</a> (and also its meta-circular interpreter, <a href="https:&#x2F;&#x2F;github.com&#x2F;nukata&#x2F;little-scheme" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nukata&#x2F;little-scheme</a>). As a Scheme implementation, it also handles first-class continuations and runs the yin-yang puzzle correctly.<p><pre><code> $ cat yin-yang-puzzle.scm ;; The yin-yang puzzle ;; cf. https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Call-with-current-continuation ((lambda (yin) ((lambda (yang) (yin yang)) ((lambda (cc) (display &#x27;*) cc) (call&#x2F;cc (lambda (c) c))))) ((lambda (cc) (newline) cc) (call&#x2F;cc (lambda (c) c)))) ;; =&gt; \n*\n**\n***\n****\n*****\n******\n... $ little-scheme-in-go yin-yang-puzzle.scm | head * ** *** **** ***** ****** ******* ******** ********* $</code></pre>