Created
April 11, 2012 14:35
-
-
Save shugo/2359698 to your computer and use it in GitHub Desktop.
Rubyでもzip_withでfibが書けた
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "immutable/stream" | |
include Immutable | |
fibs = Stream.cons{1}.tail { | |
Stream.cons{1}.tail { | |
fibs.zip_with(fibs.tail, &:+) | |
} | |
} | |
p fibs.take(10).to_list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/shugo/immutable を利用