Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Sep 21st, 2012  |  syntax: None  |  size: 0.39 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. class Baseball {
  2.         def strike = 0, ball = 0, out = 0
  3.         def s = {
  4.                 if(2 < ++strike) {
  5.                         strike = 0; o()
  6.                 }
  7.         }
  8.         def b = {
  9.                 if(3 < ++ball) {
  10.                         h()
  11.                 }
  12.         }
  13.         def o = {
  14.                 if(2 < ++out) {
  15.                         strike = ball = out = 0
  16.                 }
  17.         }
  18.         def f = {
  19.                 if(strike < 2) {
  20.                         s()
  21.                 }
  22.         }
  23.         def h = { strike = ball = 0 }
  24.         def p = { h(); o() }
  25.         def resolve = {
  26.                 it.collect {
  27.                         this[it](); "$out$strike$ball"
  28.                 }.join(",")
  29.         }
  30. }