Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blixt/go-brainfuck
This is a simple module to run or debug Brainfuck code.
https://github.com/blixt/go-brainfuck
Last synced: about 1 month ago
JSON representation
This is a simple module to run or debug Brainfuck code.
- Host: GitHub
- URL: https://github.com/blixt/go-brainfuck
- Owner: blixt
- Created: 2012-07-31T02:47:48.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-07-31T03:05:48.000Z (over 12 years ago)
- Last Synced: 2024-04-21T10:12:33.752Z (7 months ago)
- Language: Go
- Size: 93.8 KB
- Stars: 10
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Go Brainfuck
This is a simple module to run or debug Brainfuck code.
## Installation
go get github.com/blixt/go-brainfuck/brainfuck
## Examples
### Hello World
package main
import (
"github.com/blixt/go-brainfuck/brainfuck"
"os"
)
func main() {
// Print "Hello" and exit.
brainfuck.Run("++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.", "", os.Stdout)
}### More advanced & debugging
package main
import (
"fmt"
"github.com/blixt/go-brainfuck/brainfuck"
"io/ioutil"
)
func main() {
bf := &brainfuck.State{
Code: "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.",
Memory: make([]byte, 100),
Output: ioutil.Discard, // Ignore output
Debug: true,
}
// Do 100 iterations.
for i := 0; i < 100; i++ {
bf.Step()
}
// Print the current memory.
fmt.Println(bf.Memory)
}## Notes
In case of an EOF read from input, the `,` operator will be a no-op, unlike
some brainfuck implementations that will set the current value to 0 or -1.