networks: Update network-form->network.
This commit is contained in:
parent
ed03015e81
commit
236dca704d
1 changed files with 10 additions and 5 deletions
15
networks.rkt
15
networks.rkt
|
@ -254,16 +254,21 @@
|
|||
(check-equal? (f s) #f)))
|
||||
|
||||
;;; Build a network from a network form.
|
||||
(define (network-form->network bnf)
|
||||
(for/hash ([(x form) bnf])
|
||||
(values x (update-function-form->update-function form))))
|
||||
(define (network-form->network nf)
|
||||
(network
|
||||
(for/hash ([(x form) (in-hash (network-form-forms nf))])
|
||||
(values x (update-function-form->update-function form)))
|
||||
(network-form-domains nf)))
|
||||
|
||||
(module+ test
|
||||
(test-case "network-form->network"
|
||||
(define bn (network-form->network
|
||||
(make-hash '((a . (and a b)) (b . (not b))))))
|
||||
(network-form (hash 'a '(and a b)
|
||||
'b '(not b))
|
||||
(hash 'a (#f #t)
|
||||
'b (#f #t)))))
|
||||
(define s (make-state '((a . #t) (b . #t))))
|
||||
(check-equal? ((hash-ref bn 'a) s) #t)))
|
||||
(check-equal? ((hash-ref (network-functions bn) 'a) s) #t)))
|
||||
|
||||
;;; Build a network from a list of pairs of forms of update functions.
|
||||
(define (make-network-from-forms forms)
|
||||
|
|
Loading…
Reference in a new issue