Skip to content

Instantly share code, notes, and snippets.

@cthom06
cthom06 / circ.go
Created October 19, 2010 14:18
Boolean Circuits (ish) using go channels
// A fun little experiment making boolean circuits with channels
// It's pretty slow (especially with GOMAXPROCS > 1), but neat
// Originally, I had made all the gates structs with methods, etc,
// but they can all be done as functions thanks to closures/gc.
package circ
func NAND(in1, in2 <-chan bool) <-chan bool {
out := make(chan bool)
go func() {
for {