Skip to content

Commit

Permalink
Using g with negative indicies should return zero, not clamp
Browse files Browse the repository at this point in the history
  • Loading branch information
mousetail authored Jun 18, 2024
1 parent a20d69e commit f04286b
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/scripts/interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,8 @@ const commands: {[k: string]: <T>(o: ProgramState<T>) => void} = {
},
'g': (o) => {
let [y, x] = [o.number_implementation.toIndex(pop(o)), o.number_implementation.toIndex(pop(o))];
if (x < 0) {
x = 0;
}
if (y < 0) {
y = 0;
}

if (y < o.program.length && x < o.program[y].length) {

if (x >= 0 && y >= 0 && y < o.program.length && x < o.program[y].length) {
push(
o,
o.program[y][x]
Expand Down Expand Up @@ -307,4 +301,4 @@ export function step(o: AnyTypeProgramState) {
} else {
_step<Rational>(o)
}
}
}

0 comments on commit f04286b

Please sign in to comment.