diff --git a/networks.rkt b/networks.rkt index 0c12d86..cfb21e3 100644 --- a/networks.rkt +++ b/networks.rkt @@ -63,14 +63,11 @@ ;;; Given a state s updates all the variables from xs. This ;;; corresponds to a parallel mode. -(define (update n ; the network - s ; the state to operate on - xs) ; the variables to update - (let ([new-s (hash-copy s)]) - (for ([x xs]) - (let ([f (hash-ref n x)]) - (hash-set! new-s x (f s)))) - new-s)) +(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))))) ;;; A version of make-immutable-hash restricted to creating network ;;; states (see contract).