print-org-tbfs/state → tbfs/state->lists
print-org-tbfs/state+headers → tbfs/state->lists+headers
This commit is contained in:
parent
b1b78917ce
commit
08d41dd4ca
2 changed files with 18 additions and 18 deletions
|
@ -201,7 +201,7 @@ is taken to contain the names of the variables, similarly to
|
||||||
(read-org-tbfs/state+headers "((a b f) (1 2 3) (1 1 2))")
|
(read-org-tbfs/state+headers "((a b f) (1 2 3) (1 1 2))")
|
||||||
]}
|
]}
|
||||||
|
|
||||||
@defproc[(print-org-tbfs/state [tbfs (Listof TBF/State)]) (Listof (Listof Real))]{
|
@defproc[(tbfs/state->lists [tbfs (Listof TBF/State)]) (Listof (Listof Real))]{
|
||||||
|
|
||||||
Given a list of @racket[TBF/State], produces a sexp that Org-mode can
|
Given a list of @racket[TBF/State], produces a sexp that Org-mode can
|
||||||
interpret as a table.
|
interpret as a table.
|
||||||
|
@ -210,20 +210,20 @@ All @racket[TBF/State] in the list must have the same inputs.
|
||||||
The function does not check this property.
|
The function does not check this property.
|
||||||
|
|
||||||
@ex[
|
@ex[
|
||||||
(print-org-tbfs/state (list (tbf/state (hash 'a 1 'b 2) 3)
|
(tbfs/state->lists (list (tbf/state (hash 'a 1 'b 2) 3)
|
||||||
(tbf/state (hash 'a -2 'b 1) 1)))
|
(tbf/state (hash 'a -2 'b 1) 1)))
|
||||||
]}
|
]}
|
||||||
|
|
||||||
@defproc[(print-org-tbfs/state+headers [tbfs (Listof TBF/State)])
|
@defproc[(tbfs/state->lists+headers [tbfs (Listof TBF/State)])
|
||||||
(Pairof (Listof Variable) (Listof (Listof Real)))]{
|
(Pairof (Listof Variable) (Listof (Listof Real)))]{
|
||||||
|
|
||||||
Like @racket[print-org-tbfs/state], but the first list of the result
|
Like @racket[tbfs/state->lists+headers], but the first list of the
|
||||||
is the list of input names of the first @racket[TBF/State] in
|
result is the list of input names of the first @racket[TBF/State] in
|
||||||
@racket[tbfs]. The last element of this first list is @racket['θ] and
|
@racket[tbfs]. The last element of this first list is @racket['θ] and
|
||||||
corresponds to the column giving the thresholds of the TBFs.
|
corresponds to the column giving the thresholds of the TBFs.
|
||||||
|
|
||||||
@ex[
|
@ex[
|
||||||
(print-org-tbfs/state+headers
|
(tbfs/state->lists+headers
|
||||||
(list (tbf/state (hash 'a 1 'b 2) 3)
|
(list (tbf/state (hash 'a 1 'b 2) 3)
|
||||||
(tbf/state (hash 'a -2 'b 1) 1)))
|
(tbf/state (hash 'a -2 'b 1) 1)))
|
||||||
]}
|
]}
|
||||||
|
|
20
tbn.rkt
20
tbn.rkt
|
@ -28,7 +28,7 @@
|
||||||
lists+vars->tbfs/state lists+headers->tbfs/state lists->tbfs/state
|
lists+vars->tbfs/state lists+headers->tbfs/state lists->tbfs/state
|
||||||
lists+vars->sbfs/state lists+headers->sbfs/state lists->sbfs/state
|
lists+vars->sbfs/state lists+headers->sbfs/state lists->sbfs/state
|
||||||
read-org-tbfs/state read-org-tbfs/state+headers
|
read-org-tbfs/state read-org-tbfs/state+headers
|
||||||
print-org-tbfs/state print-org-tbfs/state+headers
|
tbfs/state->lists tbfs/state->lists+headers
|
||||||
)
|
)
|
||||||
|
|
||||||
(: apply-tbf-to-state (-> TBF (State (U Zero One)) (U Zero One)))
|
(: apply-tbf-to-state (-> TBF (State (U Zero One)) (U Zero One)))
|
||||||
|
@ -183,32 +183,32 @@
|
||||||
(list (tbf/state '#hash((a . 1) (b . 2)) 3)
|
(list (tbf/state '#hash((a . 1) (b . 2)) 3)
|
||||||
(tbf/state '#hash((a . 1) (b . 1)) 2)))))
|
(tbf/state '#hash((a . 1) (b . 1)) 2)))))
|
||||||
|
|
||||||
(: print-org-tbfs/state (-> (Listof TBF/State) (Listof (Listof Real))))
|
(: tbfs/state->lists (-> (Listof TBF/State) (Listof (Listof Real))))
|
||||||
(define (print-org-tbfs/state tbfs)
|
(define (tbfs/state->lists tbfs)
|
||||||
(for/list ([tbf (in-list tbfs)])
|
(for/list ([tbf (in-list tbfs)])
|
||||||
(append (hash-map (tbf/state-w tbf) (λ (_ [w : Real]) w) #t)
|
(append (hash-map (tbf/state-w tbf) (λ (_ [w : Real]) w) #t)
|
||||||
(list (tbf/state-θ tbf)))))
|
(list (tbf/state-θ tbf)))))
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(test-case "print-org-tbfs/state"
|
(test-case "tbfs/state->lists"
|
||||||
(check-equal?
|
(check-equal?
|
||||||
(print-org-tbfs/state (list (tbf/state (hash 'a 1 'b 2) 3)
|
(tbfs/state->lists (list (tbf/state (hash 'a 1 'b 2) 3)
|
||||||
(tbf/state (hash 'a -2 'b 1) 1)))
|
(tbf/state (hash 'a -2 'b 1) 1)))
|
||||||
'((1 2 3) (-2 1 1)))))
|
'((1 2 3) (-2 1 1)))))
|
||||||
|
|
||||||
(: print-org-tbfs/state+headers (-> (Listof TBF/State)
|
(: tbfs/state->lists+headers (-> (Listof TBF/State)
|
||||||
(Pairof (Listof Variable)
|
(Pairof (Listof Variable)
|
||||||
(Listof (Listof Real)))))
|
(Listof (Listof Real)))))
|
||||||
(define (print-org-tbfs/state+headers tbfs)
|
(define (tbfs/state->lists+headers tbfs)
|
||||||
(cons (append (hash-map (tbf/state-w (car tbfs))
|
(cons (append (hash-map (tbf/state-w (car tbfs))
|
||||||
(λ ([x : Symbol] _) x) #t)
|
(λ ([x : Symbol] _) x) #t)
|
||||||
'(θ))
|
'(θ))
|
||||||
(print-org-tbfs/state tbfs)))
|
(tbfs/state->lists tbfs)))
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(test-case "print-org-tbfs/state+headers"
|
(test-case "tbfs/state->list+headers"
|
||||||
(check-equal?
|
(check-equal?
|
||||||
(print-org-tbfs/state+headers (list (tbf/state (hash 'a 1 'b 2) 3)
|
(tbfs/state->lists+headers (list (tbf/state (hash 'a 1 'b 2) 3)
|
||||||
(tbf/state (hash 'a -2 'b 1) 1)))
|
(tbf/state (hash 'a -2 'b 1) 1)))
|
||||||
'((a b θ)
|
'((a b θ)
|
||||||
(1 2 3)
|
(1 2 3)
|
||||||
|
|
Loading…
Reference in a new issue