bn: Add update-func-form->update-func.
This commit is contained in:
parent
a061e2d7bc
commit
7a4dd09f40
2 changed files with 14 additions and 2 deletions
|
@ -30,4 +30,9 @@
|
|||
[new-s (update bn s '(x2 x1))])
|
||||
(check-equal? (hash-ref new-s 'x1) #f)
|
||||
(check-equal? (hash-ref new-s 'x2) #t)
|
||||
(check-equal? (length (hash-keys new-s)) 2))))))
|
||||
(check-equal? (length (hash-keys new-s)) 2)))
|
||||
|
||||
(test-case "Constructing networks from forms"
|
||||
(let ([s (make-state '((x . #t) (y . #f)))]
|
||||
[f (update-func-form->update-func '(and x y))])
|
||||
(check-equal? (f s) #f))))))
|
||||
|
|
9
bn.rkt
9
bn.rkt
|
@ -7,8 +7,10 @@
|
|||
;;; are updated according to their corresponding update functions.
|
||||
;;; The variables to be updated at each step are given by the mode.
|
||||
|
||||
(require "utils.rkt")
|
||||
|
||||
(provide Variable State UpdateFunc Network
|
||||
update make-state make-bn)
|
||||
update make-state make-bn update-func-form->update-func)
|
||||
|
||||
|
||||
;;; =================
|
||||
|
@ -65,3 +67,8 @@
|
|||
;;; forms of their update functions.
|
||||
(define-type NetworkForm (HashTable Variable UpdateFuncForm))
|
||||
|
||||
;;; Build an update function from an update function form.
|
||||
#;(: update-func-form->update-func (-> UpdateFuncForm UpdateFunc))
|
||||
(define (update-func-form->update-func form)
|
||||
(lambda ([s : State])
|
||||
(cast (eval-with1 (cast s (HashTable Variable Any)) form) Boolean)))
|
||||
|
|
Loading…
Reference in a new issue