Add lists->tbfs/state.
This commit is contained in:
parent
3455b8aae1
commit
43d782f149
2 changed files with 25 additions and 1 deletions
|
@ -144,3 +144,14 @@ line (the threshold column) is discarded.
|
|||
@ex[
|
||||
(lists+headers->tbfs/state '((x y f) (1 2 3) (1 1 2)))
|
||||
]}
|
||||
|
||||
@defproc[(lists->tbfs/state [lsts (Listof (Liostf Real))])
|
||||
(Listof TBF/State)]{
|
||||
|
||||
Like @racket[lists+vars->tbfs/state], but the names of the variables
|
||||
are generated as @tt{xi}, where @italic{i} is the index of the
|
||||
variable, starting from 0.
|
||||
|
||||
@ex[
|
||||
(lists->tbfs/state '((1 2 3) (1 1 2)))
|
||||
]}
|
||||
|
|
15
tbn.rkt
15
tbn.rkt
|
@ -25,7 +25,7 @@
|
|||
(struct-out tbf/state) TBF/State tbf/state-w tbf/state-θ make-tbf/state
|
||||
sbf/state? apply-tbf/state
|
||||
|
||||
lists+vars->tbfs/state lists+headers->tbfs/state
|
||||
lists+vars->tbfs/state lists+headers->tbfs/state lists->tbfs/state
|
||||
)
|
||||
|
||||
(: apply-tbf-to-state (-> TBF (State (U Zero One)) (U Zero One)))
|
||||
|
@ -105,6 +105,19 @@
|
|||
(check-equal? (lists+headers->tbfs/state '((x y f) (1 2 3) (1 1 2)))
|
||||
(list (tbf/state '#hash((x . 1) (y . 2)) 3)
|
||||
(tbf/state '#hash((x . 1) (y . 1)) 2)))))
|
||||
|
||||
(: lists->tbfs/state (-> (Listof (Listof Real)) (Listof TBF/State)))
|
||||
(define (lists->tbfs/state lsts)
|
||||
(lists+vars->tbfs/state
|
||||
(for/list ([i (in-range (length (car lsts)))])
|
||||
(string->symbol (format "x~a" i)))
|
||||
lsts))
|
||||
|
||||
(module+ test
|
||||
(test-case "lists->tbfs/state"
|
||||
(check-equal? (lists->tbfs/state '((1 2 3) (1 1 2)))
|
||||
(list (tbf/state '#hash((x0 . 1) (x1 . 2)) 3)
|
||||
(tbf/state '#hash((x0 . 1) (x1 . 1)) 2)))))
|
||||
)
|
||||
|
||||
(module+ test
|
||||
|
|
Loading…
Reference in a new issue