From 713ded5adb0da1c0d284608c698cc109354eea7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Sat, 26 May 2018 22:55:07 +0300 Subject: [PATCH] Handle non-empty memory in ircbotRun(). Turns out [].reduce() passes 4 parameters --- gir.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gir.js b/gir.js index 18c783d..7241402 100644 --- a/gir.js +++ b/gir.js @@ -976,8 +976,8 @@ function ircbotRun(program, input, maxCycles = 400000) { // even if there are no indices we can get values that // the rest of the code can work with let memoryIndices = Array.from(result.state.memory.keys()); - let min = memoryIndices.reduce(Math.min, tapeHead); - let max = memoryIndices.reduce(Math.max, tapeHead); + let min = memoryIndices.reduce((x,y) => Math.min(x, y), tapeHead); + let max = memoryIndices.reduce((x,y) => Math.max(x, y), tapeHead); // Get 15 cells of context on each side of tape head // Exception is if max or min comes up before that, in which