Documentation
¶
Overview ¶
Package intcode implements an intcode computer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Computer ¶
type Computer struct { Done chan struct{} Input chan int Output chan int Err chan error // contains filtered or unexported fields }
Computer is an opcode computer. Input is read through the Input channel, output from the Output channel; the "halt" instruction closes the Done channel, and any errors can be read from the Err channel.
func NewComputer ¶
NewComputer returns an opcode computer with its memory initalized to opcodes.
func (*Computer) StartProgram ¶
func (c *Computer) StartProgram()
StartProgram starts a goroutine that executes the program in the memory of the computer. It is typically used like this:
Loop: for { select { case v := <-c.Output: // Do something with output. case <-c.Done: break Loop case err := <-c.Err: // Handle error. } }
Click to show internal directories.
Click to hide internal directories.