From 401f895dd23c1d8287fe25b54c89326462b04b2d Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Sun, 22 Mar 2020 19:34:08 +0100 Subject: [PATCH] networks: Make build-all-states order the variables. --- networks-tests.rkt | 12 ++++++------ networks.rkt | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/networks-tests.rkt b/networks-tests.rkt index 0db273d..a97c19d 100644 --- a/networks-tests.rkt +++ b/networks-tests.rkt @@ -247,17 +247,17 @@ (random-seed 0) (define f (random-boolean-function/state '(x1 x2))) (check-equal? (tabulate-state/boolean f '(x1 x2)) - '((x1 x2 f) (#f #f #f) (#t #f #f) (#f #t #t) (#t #t #t))) + '((x1 x2 f) (#f #f #f) (#f #t #f) (#t #f #t) (#t #t #t))) (check-equal? (tabulate-state/boolean f '(x1 x2) #:headers #f) - '((#f #f #f) (#t #f #f) (#f #t #t) (#t #t #t))) + '((#f #f #f) (#f #t #f) (#t #f #t) (#t #t #t))) (define bn (random-boolean-network/vars 3)) (check-equal? (tabulate-boolean-network bn) '((x0 x1 x2 f-x0 f-x1 f-x2) (#f #f #f #f #t #f) - (#f #t #f #t #f #f) - (#f #f #t #f #t #t) + (#f #f #t #t #f #f) + (#f #t #f #f #t #t) (#f #t #t #t #f #f) (#t #f #f #t #f #t) - (#t #t #f #f #f #t) - (#t #f #t #f #f #f) + (#t #f #t #f #f #t) + (#t #t #f #f #f #f) (#t #t #t #t #t #t))))) diff --git a/networks.rkt b/networks.rkt index a8d4658..5e4ac60 100644 --- a/networks.rkt +++ b/networks.rkt @@ -219,7 +219,7 @@ ;;; Given a hash-set mapping variables to generic sets of their ;;; possible values, constructs the list of all possible states. (define (build-all-states vars-domains) - (let* ([var-dom-list (hash->list vars-domains)] + (let* ([var-dom-list (hash-map vars-domains (λ (x y) (cons x y)) #t)] [vars (map car var-dom-list)] [domains (map cdr var-dom-list)]) (for/list ([s (apply cartesian-product domains)])