From 354fad2b1d8a626b0df6f83d44f0b0317876febe Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Sun, 22 Nov 2020 22:50:29 +0100 Subject: [PATCH] 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 --- networks.rkt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/networks.rkt b/networks.rkt index 2923a53..426a91a 100644 --- a/networks.rkt +++ b/networks.rkt @@ -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"