bn: Add and use make-bn.

This commit is contained in:
Sergiu Ivanov 2020-02-15 21:00:20 +01:00
parent 1e931102d6
commit 5408f6682b
2 changed files with 6 additions and 2 deletions

View file

@ -16,7 +16,7 @@
[f2 (λ ([s : State])
(let ([x2 (hash-ref s 'x2)])
(not x2)))]
[bn (hash 'x1 f1 'x2 f2)])
[bn (make-bn `((x1 . ,f1) (x2 . ,f2)))])
(test-case "One-step syncronous update"
(let* ([s (new-state '((x1 . #t) (x2 . #f)))]

6
bn.rkt
View file

@ -8,7 +8,7 @@
;;; The variables to be updated at each step are given by the mode.
(provide Variable State UpdateFunc Network
update new-state)
update new-state make-bn)
(define-type Variable Symbol)
@ -38,3 +38,7 @@
;;; A version of make-hash restricted to creating Boolean states.
(define (new-state [mappings : (Listof (Pairof Variable Boolean))])
(make-hash mappings))
;;; A version of make-hash restricted to creating Boolean networks.
(define (make-bn [funcs : (Listof (Pairof Variable UpdateFunc))])
(make-hash funcs))