From 2c68055818d8baf18d97925cecad436dea279a7a Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Sun, 22 Nov 2020 21:42:41 +0100 Subject: [PATCH] networks: Fix constructing functions and networks. --- networks.rkt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/networks.rkt b/networks.rkt index e4d4f32..56b1dfb 100644 --- a/networks.rkt +++ b/networks.rkt @@ -962,6 +962,9 @@ ;;; ;;; This function relies on table->function, so the same caveats ;;; apply. +;;; +;;; This function sets the domain mappings of the network to the empty +;;; hash table. (define (table->network table #:headers [headers #t]) (define n (/ (length (car table)) 2)) ;; Get the variable names from the table or generate them, if @@ -984,7 +987,7 @@ (table->function (for/list ([in st-ins] [o out]) (list in o))))) ;; Construct the network. - (make-network-from-functions (map cons var-names funcs))) + (network (map cons var-names funcs) (hash))) (module+ test (test-case "table->network" @@ -993,8 +996,8 @@ (#f #t #f #t) (#t #f #t #f) (#t #t #t #t)))) - (define f1 (hash-ref n 'x1)) - (define f2 (hash-ref n 'x2)) + (define f1 (hash-ref (network-functions n) 'x1)) + (define f2 (hash-ref (network-functions n) 'x2)) (check-false (f1 (make-state '((x1 . #f) (x2 . #f))))) (check-false (f1 (make-state '((x1 . #f) (x2 . #t)))))