bn: Add st.

This commit is contained in:
Sergiu Ivanov 2020-02-18 12:39:11 +01:00
parent f4d7197f47
commit cf2cc484bf
2 changed files with 5 additions and 2 deletions

View file

@ -40,7 +40,7 @@
(b . (not b))))] (b . (not b))))]
[bn3 (bn '((a . (and a b)) [bn3 (bn '((a . (and a b))
(b . (not b))))] (b . (not b))))]
[s (make-state '((a . #t) (b . #t)))]) [s (st '((a . #t) (b . #t)))])
(check-equal? ((hash-ref bn1 'a) s) #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))) (check-equal? ((hash-ref bn3 'a) s) #t)))

5
bn.rkt
View file

@ -16,7 +16,7 @@
update make-state make-bn-funcs update-func-form->update-func update make-state make-bn-funcs update-func-form->update-func
bn-form->bn make-bn-forms bn-form->bn make-bn-forms
;; Syntax ;; Syntax
bn) st bn)
;;; ================= ;;; =================
@ -54,6 +54,9 @@
(define (make-state mappings) (define (make-state mappings)
(make-hash mappings)) (make-hash mappings))
;;; A shortcut for make-state.
(define-syntax-rule (st mappings) (make-state mappings))
;;; A version of make-hash restricted to creating Boolean networks. ;;; A version of make-hash restricted to creating Boolean networks.
(: make-bn-funcs (-> (Listof (Pairof Variable UpdateFunc)) Network)) (: make-bn-funcs (-> (Listof (Pairof Variable UpdateFunc)) Network))
(define (make-bn-funcs funcs) (define (make-bn-funcs funcs)