Type pretty-print-boolean-state.
This commit is contained in:
parent
6d2034f9e5
commit
b1cc242c7b
2 changed files with 20 additions and 0 deletions
11
networks.rkt
11
networks.rkt
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
Modality Mode dynamics% Dynamics% make-syn make-asyn
|
Modality Mode dynamics% Dynamics% make-syn make-asyn
|
||||||
make-asyn-dynamics make-syn-dynamics pretty-print-state
|
make-asyn-dynamics make-syn-dynamics pretty-print-state
|
||||||
|
pretty-print-boolean-state
|
||||||
)
|
)
|
||||||
|
|
||||||
(define-type (State a) (VariableMapping a))
|
(define-type (State a) (VariableMapping a))
|
||||||
|
@ -664,6 +665,16 @@
|
||||||
(test-case "pretty-print-state"
|
(test-case "pretty-print-state"
|
||||||
(check-equal? (pretty-print-state (hash 'a #f 'b 3 'c 4))
|
(check-equal? (pretty-print-state (hash 'a #f 'b 3 'c 4))
|
||||||
"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)
|
(require 'typed)
|
||||||
|
|
|
@ -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}
|
@section{Inferring interaction graphs}
|
||||||
|
|
||||||
This section provides inference of both unsigned and signed interaction graphs.
|
This section provides inference of both unsigned and signed interaction graphs.
|
||||||
|
|
Loading…
Reference in a new issue