Type pretty-print-boolean-state.

This commit is contained in:
Sergiu Ivanov 2022-09-19 00:10:42 +02:00
parent 6d2034f9e5
commit b1cc242c7b
2 changed files with 20 additions and 0 deletions

View File

@ -35,6 +35,7 @@
Modality Mode dynamics% Dynamics% make-syn make-asyn
make-asyn-dynamics make-syn-dynamics pretty-print-state
pretty-print-boolean-state
)
(define-type (State a) (VariableMapping a))
@ -664,6 +665,16 @@
(test-case "pretty-print-state"
(check-equal? (pretty-print-state (hash 'a #f 'b 3 'c 4))
"a:#f b:3 c:4")))
(: pretty-print-boolean-state (All (a) (-> (State a) String)))
(define (pretty-print-boolean-state s)
(string-join (hash-map s (λ (key val) (format "~a:~a" key (any->01 val))) #t)))
(module+ test
(test-case "pretty-print-boolean-state"
(check-equal?
(pretty-print-boolean-state (hash 'a #f 'b #t 'c #t))
"a:0 b:1 c:1")))
)
(require 'typed)

View File

@ -476,6 +476,15 @@ Pretty-prints a state of a network.
}
@defproc[(pretty-print-boolean-state [s (State a)]) String]{
Pretty-prints a state of a network, replacing all @racket[#f] values with 0 and
all other values with 1.
@ex[(pretty-print-boolean-state (hash 'a #f 'b 3 'c '() 'd #t))]
}
@section{Inferring interaction graphs}
This section provides inference of both unsigned and signed interaction graphs.