Skip to content

Instantly share code, notes, and snippets.

View HeGanjie's full-sized avatar

Bruce He HeGanjie

View GitHub Profile

在LISP之根源里面看到作者提到Y组合子,于是去了解了一下,但是看其他人的解释都很难完全弄懂。
最后通过 王垠的wiki 发现 Franco 教授的推演过程讲得最简单易懂,在看懂了之后我再用CoffeeScript推演了一次,加深理解。

LISP之根源 http://daiyuwen.freeshell.org/gb/rol/roots_of_lisp.html#foot108
王垠的wiki http://minus273.eu/mirrors/2001315450/wiki/SchemeYcombinator.html
Franco 教授的推演过程 http://www.ece.uc.edu/~franco/C511/html/Scheme/ycomb.html
可以将代码贴在这里上面验证结果 http://coffeescript.org/

  • 第一步

Stream是一种能容纳无穷对象的容器,我在研究了Js的实现后,尝试用Ruby实现一下。另外加上阶乘数列和 费波纳茨数列的实现。
Stream.js的介绍: http://www.aqee.net/stream-javascript-lib/
Stream的详情请参考: http://www.aqee.net/docs/stream/

class Stream
	def initialize(head = nil, tail = nil)
		@head = head
		@tailFunc = tail
	end