Subleq: Difference between revisions

Content added Content deleted
(Remove specification of how emulated memory is to be initialized)
m (→‎{{header|Ruby}}: mild idiomaticity adjustment)
Line 2,775: Line 2,775:
<lang Ruby>class Computer
<lang Ruby>class Computer
def initialize program
def initialize program
@memory = program.map{|instruction| instruction.to_i}
@memory = program.map &:to_i
@instruction_pointer = 0
@instruction_pointer = 0
end
end
Line 2,790: Line 2,790:
writechar @memory[a]
writechar @memory[a]
else
else
difference = @memory[b] - @memory[a]
difference = @memory[b] -= @memory[a]
@memory[b] = difference
@instruction_pointer = c if difference <= 0
@instruction_pointer = c if difference <= 0
end
end