3 ms·
I think this also caches closures, and recomputes them either when the inputs change or the closed over values are mutated. Edit: Oh, apparently that's not the
by pygy_ 5y ago
I think this also caches closures, and recomputes them either when the inputs change or the closed over values are mutated.
Edit: Oh, apparently that's not the case... Or maybe I missed something.
http://skiplang.com/playground/#bXV0YWJsZSBjbGFzcyBGb28obXV0YWJsZSB4OkludCkgewogIG11dGFibGUgZnVuIGdldCgpIDpJbnQgewogICAgZGVidWcoKCJnZXR0aW5nIiwgdGhpcykpOwogICAgdGhpcy54CiAgfQp9CgpmdW4gbWFpbigpOiB2b2lkIHsKICBmb28gPSBtdXRhYmxlIEZvbygwKTsKICBmID0gKHg6SW50LCB5Om11dGFibGUgRm9vKSAtPiB4ICsgeS5nZXQoKTsKICBkZWJ1ZyhmKDEsIGZvbykpOwogIGRlYnVnKGYoMSwgZm9vKSk7CiAgZm9vLiF4PTE7CiAgZGVidWcoZigxLCBmb28pKTsKICAKfQo= http://skiplang.com/playground/#bXV0YWJsZSBjbGFzcyBGb28obXV0...
Edit2: `debug()` is tracked as an effect, causing `get()` not to be memoized. Unfortunate...
http://skiplang.com/playground/#bXV0YWJsZSBjbGFzcyBGb28obXV0YWJsZSB4OkludCkgewogIG11dGFibGUgZnVuIGdldCgpIDpJbnQgewogICAgZGVidWcoKCJnZXR0aW5nIiwgdGhpcykpOwogICAgdGhpcy54CiAgfQp9CgpmdW4gbWFpbigpOiB2b2lkIHsKICBmb28gPSBtdXRhYmxlIEZvbygwKTsKICBmID0gKHg6SW50LCB5Om11dGFibGUgRm9vKSAtPiB4ICsgeS5nZXQoKTsKICBkZWJ1ZyhmKDEsIGZvbykpOwogIGRlYnVnKGYoMSwgZm9vKSk7CiAgZGVidWcoKCJiYXJlIGdldCgpIiwgZm9vLmdldCgpKSk7CiAgZm9vLiF4PTE7CiAgZGVidWcoZigxLCBmb28pKTsKICAKfQo= http://skiplang.com/playground/#bXV0YWJsZSBjbGFzcyBGb28obXV0...