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)))
|
(check-equal? (f s) #f)))
|
||||||
|
|
||||||
;;; Build a network from a network form.
|
;;; Build a network from a network form.
|
||||||
(define (network-form->network bnf)
|
(define (network-form->network nf)
|
||||||
(for/hash ([(x form) bnf])
|
(network
|
||||||
(values x (update-function-form->update-function form))))
|
(for/hash ([(x form) (in-hash (network-form-forms nf))])
|
||||||
|
(values x (update-function-form->update-function form)))
|
||||||
|
(network-form-domains nf)))
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(test-case "network-form->network"
|
(test-case "network-form->network"
|
||||||
(define bn (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))))
|
(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.
|
;;; Build a network from a list of pairs of forms of update functions.
|
||||||
(define (make-network-from-forms forms)
|
(define (make-network-from-forms forms)
|
||||||
|
|
Loading…
Reference in a new issue