[2019][ruby] explain the 3

master
Alpha Chen 5 years ago
parent a577d0b72c
commit 33786055b9

@ -94,7 +94,7 @@ class Computer
opcode = OPCODES.fetch(instruction[-2..-1].to_i) opcode = OPCODES.fetch(instruction[-2..-1].to_i)
@pc += 1 @pc += 1
n = opcode.arity - 3 n = opcode.arity - 3 # subtract the memory, input, and output params
args = (0...n).map {|i| args = (0...n).map {|i|
mode = instruction[2-i] { ?0 } mode = instruction[2-i] { ?0 }
value = @memory.fetch(@pc + i) || 0 value = @memory.fetch(@pc + i) || 0

Loading…
Cancel
Save