networks: Rewrite update for immutable hashes.
This commit is contained in:
parent
1492c33e1a
commit
4a6888ddde
1 changed files with 5 additions and 8 deletions
13
networks.rkt
13
networks.rkt
|
@ -63,14 +63,11 @@
|
||||||
|
|
||||||
;;; Given a state s updates all the variables from xs. This
|
;;; Given a state s updates all the variables from xs. This
|
||||||
;;; corresponds to a parallel mode.
|
;;; corresponds to a parallel mode.
|
||||||
(define (update n ; the network
|
(define (update network s xs)
|
||||||
s ; the state to operate on
|
(for/fold ([new-s s])
|
||||||
xs) ; the variables to update
|
([x xs])
|
||||||
(let ([new-s (hash-copy s)])
|
(let ([f (hash-ref network x)])
|
||||||
(for ([x xs])
|
(hash-set new-s x (f s)))))
|
||||||
(let ([f (hash-ref n x)])
|
|
||||||
(hash-set! new-s x (f s))))
|
|
||||||
new-s))
|
|
||||||
|
|
||||||
;;; A version of make-immutable-hash restricted to creating network
|
;;; A version of make-immutable-hash restricted to creating network
|
||||||
;;; states (see contract).
|
;;; states (see contract).
|
||||||
|
|
Loading…
Reference in a new issue