From 119fcdb8dfba179db4a4aec8931a134811049faa Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Thu, 15 Oct 2020 00:33:18 +0200 Subject: [PATCH] networks: Add make-tbn. --- networks.rkt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/networks.rkt b/networks.rkt index 96b80c7..3609ce6 100644 --- a/networks.rkt +++ b/networks.rkt @@ -100,7 +100,8 @@ [tbf/state-tabulate* (->* ((non-empty-listof tbf/state?)) (#:headers boolean?) (listof (listof (or/c symbol? number?))))] [tbf/state-tabulate (->* (tbf/state?) (#:headers boolean?) - (listof (listof (or/c symbol? number?))))]) + (listof (listof (or/c symbol? number?))))] + [make-tbn (-> (listof (cons/c variable? tbf/state?)) tbn?)]) ;; Predicates (contract-out [variable? (-> any/c boolean?)] [state? (-> any/c boolean?)] @@ -1235,3 +1236,14 @@ ;;; The tbf/state must only reference variables appearing in the ;;; network. This contract does not check this condition. (define tbn? (hash/c variable? tbf/state?)) + +;;; Builds a TBN from a list of pairs (variable, tbf/state). +(define make-tbn make-immutable-hash) + +(module+ test + (test-case "make-tbn" + (define tbf-not (make-tbf/state '((a . -1)) -1)) + (define tbf-id (make-sbf/state '((a . 1)))) + (check-equal? (make-tbn `((a . ,tbf-not) (b . ,tbf-id))) + (hash 'a (tbf/state '#hash((a . -1)) -1) + 'b (tbf/state '#hash((a . 1)) 0)))))