Skip to content

Instantly share code, notes, and snippets.

View HeGanjie's full-sized avatar

Bruce He HeGanjie

View GitHub Profile

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
@HeGanjie
HeGanjie / recur.clj
Last active October 3, 2021 05:58
CPS can't reduce the time complexity...
;fac
(defn fac [n]
(if (zero? n) 1
(* n (fac (dec n)))))
(defn fac-t [n acc] ; n 1
(if (zero? n) acc
(recur (dec n) (* acc n))))
(defn fac-c [n f] ; n identity