diff --git a/scribblings/tbn.scrbl b/scribblings/tbn.scrbl index 2cef959..9ce2259 100644 --- a/scribblings/tbn.scrbl +++ b/scribblings/tbn.scrbl @@ -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))") ]} -@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 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. @ex[ -(print-org-tbfs/state (list (tbf/state (hash 'a 1 'b 2) 3) - (tbf/state (hash 'a -2 'b 1) 1))) +(tbfs/state->lists (list (tbf/state (hash 'a 1 'b 2) 3) + (tbf/state (hash 'a -2 'b 1) 1))) ]} -@defproc[(print-org-tbfs/state+headers [tbfs (Listof TBF/State)]) - (Pairof (Listof Variable) (Listof (Listof Real)))]{ +@defproc[(tbfs/state->lists+headers [tbfs (Listof TBF/State)]) + (Pairof (Listof Variable) (Listof (Listof Real)))]{ -Like @racket[print-org-tbfs/state], but the first list of the result -is the list of input names of the first @racket[TBF/State] in +Like @racket[tbfs/state->lists+headers], but the first list of the +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 corresponds to the column giving the thresholds of the TBFs. @ex[ -(print-org-tbfs/state+headers +(tbfs/state->lists+headers (list (tbf/state (hash 'a 1 'b 2) 3) (tbf/state (hash 'a -2 'b 1) 1))) ]} diff --git a/tbn.rkt b/tbn.rkt index 06e9236..85f56a2 100644 --- a/tbn.rkt +++ b/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 - 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))) @@ -183,32 +183,32 @@ (list (tbf/state '#hash((a . 1) (b . 2)) 3) (tbf/state '#hash((a . 1) (b . 1)) 2))))) - (: print-org-tbfs/state (-> (Listof TBF/State) (Listof (Listof Real)))) - (define (print-org-tbfs/state tbfs) + (: tbfs/state->lists (-> (Listof TBF/State) (Listof (Listof Real)))) + (define (tbfs/state->lists tbfs) (for/list ([tbf (in-list tbfs)]) (append (hash-map (tbf/state-w tbf) (λ (_ [w : Real]) w) #t) (list (tbf/state-θ tbf))))) (module+ test - (test-case "print-org-tbfs/state" + (test-case "tbfs/state->lists" (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))) '((1 2 3) (-2 1 1))))) - (: print-org-tbfs/state+headers (-> (Listof TBF/State) + (: tbfs/state->lists+headers (-> (Listof TBF/State) (Pairof (Listof Variable) (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)) (λ ([x : Symbol] _) x) #t) '(θ)) - (print-org-tbfs/state tbfs))) + (tbfs/state->lists tbfs))) (module+ test - (test-case "print-org-tbfs/state+headers" + (test-case "tbfs/state->list+headers" (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))) '((a b θ) (1 2 3)