Skip to content

Instantly share code, notes, and snippets.

@aruprakshit
Created December 17, 2014 20:44
Show Gist options
  • Save aruprakshit/3ad0427885c327fb2923 to your computer and use it in GitHub Desktop.
Save aruprakshit/3ad0427885c327fb2923 to your computer and use it in GitHub Desktop.
[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]$
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