[go-nuts] Re: Trying to code an observer pattern or a publish/submit pattern for a cellular automaton

2021-11-14 Thread Serge Hulne
Here is another solution: package pubsub import ( "fmt" "math/rand" "strings" "time" ) type Node struct { Id int State int ChOutL chan int ChOutR chan int ChInL chan int ChInR chan int ChIO chan int } func NewNode(id int, state int) Node { choutL := make(chan int) choutR := make(chan int) var

[go-nuts] Re: Trying to code an observer pattern or a publish/submit pattern for a cellular automaton

2021-11-14 Thread Serge Hulne
Here is another solution: ``` package pubsub import ( "fmt" "strings" ) type Node struct { Id int State int ChOutL chan int ChOutR chan int ChInL chan int ChInR chan int ChIO chan int } func NewNode(id int, state int) Node { choutL := make(chan int) choutR := make(chan int) var chinL chan int

[go-nuts] Re: Trying to code an observer pattern or a publish/submit pattern for a cellular automaton

2021-11-14 Thread Sean Liao
that's exponential growth, every value results in 2 output values input "1" x1, get "2" x2, "3" x4, "4" x8, "5" x16, ... also your use of goroutines to send mean you'll still run out of memory at some point On Sunday, November 14, 2021 at 2:29:26 PM UTC Serge Hulne wrote: > Hi, > > I am trying

[go-nuts] Trying to code an observer pattern or a publish/submit pattern for a cellular automaton

2021-11-14 Thread Serge Hulne
Hi, I am trying to code an observer pattern or a publish/submit pattern for a sort of cellular automaton. The classical observer pattern does not to the trick because if a cell A subscribes to changes in a cell B and vice-versa, the application will run out of stack owing to the recursive