Skip to content

Instantly share code, notes, and snippets.

@Gonzih
Last active December 29, 2015 10:09
Show Gist options
  • Save Gonzih/7654912 to your computer and use it in GitHub Desktop.
Save Gonzih/7654912 to your computer and use it in GitHub Desktop.
yin-yang continuations puzzle in ruby
# http://stackoverflow.com/questions/2694679/how-does-the-yin-yang-puzzle-work
require "continuation"
yin = ->(cc) { print "@"; sleep 0.5; cc }.call(callcc { |cc| cc })
yang = ->(cc) { print "*"; sleep 0.5; cc }.call(callcc { |cc| cc })
yin.call(yang)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment