macro hanoi(from, other, to, num)
{
var state, depth, tmp;
state, depth = 1;
while (depth) {
while _neq(state, 4)
{
if (num) {
var ctx_do_push = 0;
var state1, state3 = 0;
if _eq(state, 1) { ctx_do_push = 1; state1 = 1; }
if _eq(state, 3) { ctx_do_push = 1; state3 = 1; }
if (ctx_do_push)
ctx_push(from, other, to, num, state);
if (state1) {
tmp = other; other = to; to = tmp;
num -= 1; state = 0; depth += 1;
}
if (state3) {
tmp = other; other = from; from = tmp;
num -= 1; state = 0; depth += 1;
}
}
if _eq(state, 2)
move_slice(from, to);
state += 1;
}
depth -= 1;
if (depth) {
ctx_pop(from, other, to, num, state);
state += 1;
}
}
}
|