Add lists->tbfs/state/opt-headers.
This commit is contained in:
parent
cd8cada92e
commit
afbc5426ce
2 changed files with 38 additions and 1 deletions
|
@ -156,6 +156,22 @@ variable, starting from 0.
|
|||
(lists->tbfs/state '((1 2 3) (1 1 2)))
|
||||
]}
|
||||
|
||||
@defproc[(lists->tbfs/state/opt-headers
|
||||
[lsts (Listof (Listof (U Variable Real)))]
|
||||
[#:headers hdr Boolean])
|
||||
(Listof TBF/State)]{
|
||||
|
||||
This function allows selecting between @racket[lists->tbfs/state] and
|
||||
@racket[lists+headers->tbfs/state] based on the value of @racket[hdr].
|
||||
If @racket[hdr] is @racket[#f], then @racket[lists->tbfs/state] is
|
||||
applied to @racket[lsts], otherwise @racket[lists+headers->tbfs/state]
|
||||
is applied.
|
||||
|
||||
@ex[
|
||||
(lists->tbfs/state/opt-headers '((1 2 3) (1 1 2)) #:headers #f)
|
||||
(lists->tbfs/state/opt-headers '((x y f) (1 2 3) (1 1 2)) #:headers #t)
|
||||
]}
|
||||
|
||||
@deftogether[(@defproc[(lists+vars->sbfs/state [vars (Listof Variable)]
|
||||
[lsts (Listof (Listof Real))])
|
||||
(Listof TBF/State)]
|
||||
|
|
23
tbn.rkt
23
tbn.rkt
|
@ -28,7 +28,7 @@
|
|||
lists+vars->tbfs/state lists+headers->tbfs/state lists->tbfs/state
|
||||
lists+vars->sbfs/state lists+headers->sbfs/state lists->sbfs/state
|
||||
read-org-tbfs/state read-org-tbfs/state+headers
|
||||
tbfs/state->lists tbfs/state->lists+headers
|
||||
tbfs/state->lists tbfs/state->lists+headers lists->tbfs/state/opt-headers
|
||||
sbfs/state->lists sbfs/state->lists+headers
|
||||
|
||||
tabulate-tbfs/state tabulate-tbfs/state+headers
|
||||
|
@ -130,6 +130,27 @@
|
|||
(list (tbf/state '#hash((x0 . 1) (x1 . 2)) 3)
|
||||
(tbf/state '#hash((x0 . 1) (x1 . 1)) 2)))))
|
||||
|
||||
(: lists->tbfs/state/opt-headers (-> (Listof (Listof (U Variable Real)))
|
||||
#:headers Boolean
|
||||
(Listof TBF/State)))
|
||||
(define (lists->tbfs/state/opt-headers lsts #:headers hdr)
|
||||
(if hdr
|
||||
(lists+headers->tbfs/state
|
||||
(assert-type lsts (Pairof (Listof Variable) (Listof (Listof Real)))))
|
||||
(lists->tbfs/state
|
||||
(assert-type lsts (Listof (Listof Real))))))
|
||||
|
||||
(module+ test
|
||||
(test-case "lists->tbfs/state/opt-headers"
|
||||
(check-equal?
|
||||
(lists->tbfs/state/opt-headers '((1 2 3) (1 1 2)) #:headers #f)
|
||||
(list (tbf/state '#hash((x0 . 1) (x1 . 2)) 3)
|
||||
(tbf/state '#hash((x0 . 1) (x1 . 1)) 2)))
|
||||
(check-equal?
|
||||
(lists->tbfs/state/opt-headers '((x y f) (1 2 3) (1 1 2)) #:headers #t)
|
||||
(list (tbf/state '#hash((x . 1) (y . 2)) 3)
|
||||
(tbf/state '#hash((x . 1) (y . 1)) 2)))))
|
||||
|
||||
(: lists+vars->sbfs/state (-> (Listof Variable) (Listof (Listof Real))
|
||||
(Listof TBF/State)))
|
||||
(define (lists+vars->sbfs/state vars lsts)
|
||||
|
|
Loading…
Reference in a new issue