Upgrade to Pro — share decks privately, control downloads, hide ads and more …

:|┃ / tokyu rubykaigi 12

ujihisa
July 29, 2018

:|┃ / tokyu rubykaigi 12

A tech talk at Tokyu RubyKaigi 12, featuring how to implement musical repeat sign :|┃ in Ruby, using continuation (callcc) which is a killer feature of Ruby.

ujihisa

July 29, 2018
Tweet

More Decks by ujihisa

Other Decks in Technology

Transcript

  1. require 'continuation' class String def |(x) x.() end end def

    ┃ -> { $c.call($c) } end class Proc def |(_) $c = callcc {|c| c } end end $c ||= callcc {|c| c }
  2. require 'continuation' class String def |(x) x.() end end def

    ┃ -> { $c.call($c) } end class Proc def |(_) $c = callcc {|c| c } end end $c ||= callcc {|c| c }
  3. require 'continuation' class String def |(x) x.() end end def

    ┃ -> { $c.call($c) } end class Proc def |(_) $c = callcc {|c| c } end end $c ||= callcc {|c| c }