nothing's falsity can unwind the unwary
This commit is contained in:
parent
4cb13e0a16
commit
855e55bff7
1 changed files with 49 additions and 49 deletions
|
@ -246,7 +246,6 @@ function parse_op(op: string): Option<Op> {
|
|||
case "swp":
|
||||
return op;
|
||||
}
|
||||
console.log(op);
|
||||
}
|
||||
|
||||
type State = {
|
||||
|
@ -262,7 +261,7 @@ const INITIAL_STATE: State = {
|
|||
};
|
||||
|
||||
function steps(state: State, ops: Op[], limit = 300, num_steps = 0): State[] {
|
||||
if (!ops[state.ip] || num_steps > limit) {
|
||||
if (typeof ops[state.ip] == "undefined" || num_steps > limit) {
|
||||
return [state];
|
||||
}
|
||||
return cons(
|
||||
|
@ -288,7 +287,9 @@ function step(state: State, op: Op): State {
|
|||
|
||||
if (typeof op == "number") {
|
||||
ns.stack.push(op);
|
||||
} else {
|
||||
return ns;
|
||||
}
|
||||
|
||||
switch (op) {
|
||||
case "add":
|
||||
binary_op(0, 0, (a, b) => a + b);
|
||||
|
@ -338,7 +339,6 @@ function step(state: State, op: Op): State {
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ns;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue