1. 3
  1. 1

    This is a nice solution given how hard this problem can be. Does it actually work for things like SR NOR latches?

    1. 2

      Great question. Even though supporting stuff like that is what I set out to do, I’d actually never tested it. :/

      Just now I tried creating an R-S (reset-set) flip flop, since that’s what the book I was working from when the idea came to me implements (Code, by Charles Petzold).

      And it works! Sort of.

      I think the right things are happening, but there are 2 things making it hard to work with.

      1. Because the event emitters feedback on themselves, there’s an infinite amount of output. Adding more delay helps make it manageable, and only outputing values that are changes is probably a good idea.

      2. When a gate feeds a single input into multiple internal gates, changes to the input causes the overall gate to “fire” multiple times. The answer is “right”, but it’s annoying seeing multiple values being emitted for a single input event.

      1. 1

        Fixed #2 by debouncing the emitting of events/signals for both AND and OR gates.

        Also, it’s not a flip flop or latches, but I have now implemented an Oscillator, which isn’t possible with simple pure function implementations.