Skip to content

Instantly share code, notes, and snippets.

@eatnumber1
Created July 23, 2014 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eatnumber1/2b6886e3de3f03fda0c4 to your computer and use it in GitHub Desktop.
Save eatnumber1/2b6886e3de3f03fda0c4 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'continuation'
def newG(prefix = 'g')
proc do |tail = nil|
str = prefix
cont = nil
callcc{ |cc| cont = cc }
if tail == nil
str += 'o'
newG(str)
else
str += tail
end
end
end
g = newG()
puts g.call().call().call('al')
@capicue
Copy link

capicue commented Jul 23, 2014

How is this different than

def newG(prefix = 'g')
  proc do |tail = nil|
    str = prefix
    if tail == nil
      str += 'o'
      newG(str)
    else
      str += tail
    end
  end
end

g = newG()
puts g.call().call().call('al')

@eatnumber1
Copy link
Author

Good point, it's not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment