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
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
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
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