git @ Cat's Eye Technologies Unlikely / master eg / countdown.unlikely
master

Tree @master (Download .tar.gz)

countdown.unlikely @masterraw · history · blame

class Count(Count,Chain,GreaterThan,If,Print,Subtract,Stop) extends Continuation

class Countdown(Count,Chain,GreaterThan,If,Print,Subtract,Stop) extends Program {
  Count c;
  method continue(Passive accumulator) {
    c = new Count(Passive,Count,Chain,GreaterThan,If,Print,Subtract,Stop);
    goto c.continue(new 99(Passive));
  }
}

class Count() extends Continuation {
  If i;
  GreaterThan g;
  Subtract m;
  Print p;
  Passive one;
  Passive zero;
  method continue(Passive accumulator) {
    m = new Subtract(Passive,Chain);
    m.value = accumulator;
    m.next = new Count(Passive,Count,Chain,GreaterThan,If,Print,Subtract,Stop);
    one = new 1(Passive);
    one.next = m;
    i = new If(Passive,Chain);
    i.next = one;
    i.else = new Stop(Passive);
    g = new GreaterThan(Passive,Chain);
    g.value = accumulator;
    g.next = i;
    zero = new 0(Passive);
    zero.next = g;
    p = new Print(Passive,Chain);
    p.next = zero;
    goto p.continue(accumulator);
  }
}