turing machine implementation in go
package main
import "fmt"
import s "strings"
import "strconv"
func main() {
fmt.Println(processturing("> > > + + + . ."))
}
func processturing(arguments string) string{
result := ""
dial := 0
cells := make([]int, 30000)
commands := splitstr(arguments, " ")
for i := 0;i<len(commands);i++ {
switch commands[i] {
case ">":
dial += 1
case "<":
dial -= 1
case "+":
cells[dial] += 1
case "-":
cells[dial] -= 1
case ".":
result += strconv.Itoa(cells[dial]) + " "
}
}
return result
}
//splits strings be a delimeter
func splitstr(input, delim string) []string{
return s.Split(input, delim)
}