From 236dca704d9d7918e7dd22a391198d1cdf2e281d Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Sun, 22 Nov 2020 00:25:46 +0100 Subject: [PATCH] networks: Update network-form->network. --- networks.rkt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/networks.rkt b/networks.rkt index 447c187..cb909f3 100644 --- a/networks.rkt +++ b/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)