Add tabulate-tbf/state and tabulate-tbf/state+headers.
This commit is contained in:
parent
74347b5151
commit
b9eb692091
2 changed files with 40 additions and 0 deletions
|
@ -263,3 +263,16 @@ the list.
|
|||
(list (tbf/state (hash 'a 1 'b 2) 2)
|
||||
(tbf/state (hash 'a -2 'b 2) 1)))
|
||||
]}
|
||||
|
||||
@deftogether[(@defproc[(tabulate-tbf/state [tbf TBF/State])
|
||||
(Listof (Listof Real))]
|
||||
@defproc[(tabulate-tbf/state+headers [tbf TBF/State])
|
||||
(Pairof (Listof Variable) (Listof (Listof Real)))])]{
|
||||
|
||||
Like @racket[tabulate-tbfs/state] and
|
||||
@racket[tabulate-tbfs/state+headers], but only tabulate single TBFs.
|
||||
|
||||
@ex[
|
||||
(tabulate-tbf/state (tbf/state (hash 'a 1 'b 2) 2))
|
||||
(tabulate-tbf/state+headers (tbf/state (hash 'a 1 'b 2) 2))
|
||||
]}
|
||||
|
|
27
tbn.rkt
27
tbn.rkt
|
@ -31,6 +31,7 @@
|
|||
tbfs/state->lists tbfs/state->lists+headers
|
||||
|
||||
tabulate-tbfs/state tabulate-tbfs/state+headers
|
||||
tabulate-tbf/state tabulate-tbf/state+headers
|
||||
)
|
||||
|
||||
(: apply-tbf-to-state (-> TBF (State (U Zero One)) (U Zero One)))
|
||||
|
@ -262,6 +263,32 @@
|
|||
(0 1 0 1)
|
||||
(1 0 0 0)
|
||||
(1 1 1 0)))))
|
||||
|
||||
(: tabulate-tbf/state (-> TBF/State (Listof (Listof Real))))
|
||||
(define (tabulate-tbf/state tbf)
|
||||
(tabulate-tbfs/state (list tbf)))
|
||||
|
||||
(module+ test
|
||||
(test-case "tabulate-tbf/state"
|
||||
(check-equal? (tabulate-tbf/state (tbf/state (hash 'a 1 'b 2) 2))
|
||||
'((0 0 0)
|
||||
(0 1 0)
|
||||
(1 0 0)
|
||||
(1 1 1)))))
|
||||
|
||||
(: tabulate-tbf/state+headers (-> TBF/State (Pairof (Listof Variable)
|
||||
(Listof (Listof Real)))))
|
||||
(define (tabulate-tbf/state+headers tbf)
|
||||
(tabulate-tbfs/state+headers (list tbf)))
|
||||
|
||||
(module+ test
|
||||
(test-case "tabulate-tbf/state+headers"
|
||||
(check-equal? (tabulate-tbf/state+headers (tbf/state (hash 'a 1 'b 2) 2))
|
||||
'((a b f1)
|
||||
(0 0 0)
|
||||
(0 1 0)
|
||||
(1 0 0)
|
||||
(1 1 1)))))
|
||||
)
|
||||
|
||||
(module+ test
|
||||
|
|
Loading…
Reference in a new issue