network: Roll back update to its previous version.

I thought I was clever to rewrite update using for/hash, but in fact
this new version only included the updated variables in the new
state :D
This commit is contained in:
Sergiu Ivanov 2020-11-22 22:50:29 +01:00
parent 3abf548ac2
commit 354fad2b1d
1 changed files with 4 additions and 2 deletions

View File

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