Skip to content

Instantly share code, notes, and snippets.

View Jared-Prime's full-sized avatar
📚

Jared Davis Jared-Prime

📚
View GitHub Profile
@alandipert
alandipert / fibers.rb
Created May 7, 2011 20:42
Clojure-inspired fibonacci streams with Fibers
require 'fiber'
class Fiber
def map &block
Fiber.new { loop { Fiber.yield block.call(resume) } }
end
def to_a
[].tap{|xs| xs << resume while alive?}