From 85feab230f8c43a7847f87b8694afabe30f4c993 Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Sun, 18 Oct 2020 22:52:05 +0200 Subject: [PATCH] networks: Add make-01-domains. --- networks.rkt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/networks.rkt b/networks.rkt index 15e6302..66bbd9b 100644 --- a/networks.rkt +++ b/networks.rkt @@ -32,6 +32,7 @@ [build-all-states (-> domain-mapping/c (listof state?))] [make-same-domains (-> (listof variable?) generic-set? domain-mapping/c)] [make-boolean-domains (-> (listof variable?) (hash/c variable? (list/c #f #t)))] + [make-01-domains (-> (listof variable?) (hash/c variable? (list/c 0 1)))] [build-all-boolean-states (-> (listof variable?) (listof state?))] [get-interaction-sign (-> network? domain-mapping/c variable? variable? (or/c '+ '- '0))] [build-signed-interaction-graph/form (-> network-form? domain-mapping/c graph?)] @@ -335,6 +336,16 @@ (check-equal? (make-boolean-domains '(a b)) #hash((a . (#f #t)) (b . (#f #t)))))) +;;; Makes a hash set mapping all variables to the Boolean domain, +;;; expressed as {0,1}. +(define (make-01-domains vars) + (make-same-domains vars '(0 1))) + +(module+ test + (test-case "make-01-domains" + (check-equal? (make-01-domains '(a b)) + '#hash((a . (0 1)) (b . (0 1)))))) + ;;; Builds all boolean states possible over a given set of variables. (define (build-all-boolean-states vars) (build-all-states (make-boolean-domains vars)))