From 74b57c81d774a33806a3645993b9764ace3053e9 Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Tue, 18 Feb 2020 12:36:26 +0100 Subject: [PATCH] bn: Add syntax bn. --- bn-tests.rkt | 5 ++++- bn.rkt | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bn-tests.rkt b/bn-tests.rkt index 6394226..56e3c2c 100644 --- a/bn-tests.rkt +++ b/bn-tests.rkt @@ -38,6 +38,9 @@ (let ([bn1 (bn-form->bn (make-hash '((a . (and a b)) (b . (not b)))))] [bn2 (make-bn-forms '((a . (and a b)) (b . (not b))))] + [bn3 (bn '((a . (and a b)) + (b . (not b))))] [s (make-state '((a . #t) (b . #t)))]) (check-equal? ((hash-ref bn1 'a) s) #t) - (check-equal? ((hash-ref bn2 'a) s) #t))) + (check-equal? ((hash-ref bn2 'a) s) #t) + (check-equal? ((hash-ref bn3 'a) s) #t))) diff --git a/bn.rkt b/bn.rkt index cc9fc81..560a2da 100644 --- a/bn.rkt +++ b/bn.rkt @@ -11,7 +11,8 @@ (provide Variable State UpdateFunc Network update make-state make-bn-funcs update-func-form->update-func - bn-form->bn make-bn-forms) + bn-form->bn make-bn-forms + bn) ;;; ================= @@ -85,3 +86,6 @@ (: make-bn-forms (-> (Listof (Pairof Variable UpdateFuncForm)) Network)) (define (make-bn-forms forms) (bn-form->bn (make-hash forms))) + +;;; A shortcut for make-bn-forms. +(define-syntax-rule (bn forms) (make-bn-forms forms))