networks: Rewrite update.

This commit is contained in:
Sergiu Ivanov 2020-11-21 23:28:30 +01:00
parent 6560dcbe6c
commit 11d75bcc89

View file

@ -181,10 +181,9 @@
;;; Given a state s updates all the variables from xs.
(define (update network s xs)
(for/fold ([new-s s])
([x xs])
(let ([f (hash-ref network x)])
(hash-set new-s x (f s)))))
(define funcs (network-functions network))
(for/hash ([x xs])
(x ((hash-ref funcs x) s))))
(module+ test
(test-case "basic definitions"