-
-
Save aruprakshit/3ad0427885c327fb2923 to your computer and use it in GitHub Desktop.
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
[arup@Ruby]$ ruby a.rb | |
a.rb:7: syntax error, unexpected keyword_do_block | |
do |y| | |
^ | |
a.rb:10: syntax error, unexpected keyword_end, expecting end-of-input | |
[arup@Ruby]$ |
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
def seq(first, size) | |
e = Enumerator.new(yield(first)) | |
e.take(size) | |
end | |
res = seq(5, 4) do |n| | |
do |y| | |
loop { y << n; n = 2*n - 3 } | |
end | |
end | |
p res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment