networks: Update network-form->network.

This commit is contained in:
Sergiu Ivanov 2020-11-22 00:25:46 +01:00
parent ed03015e81
commit 236dca704d

View File

@ -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)