Replace /boolean with /01.

This commit is contained in:
Sergiu Ivanov 2022-09-22 01:06:16 +02:00
parent d00056affb
commit f8a03659d1
2 changed files with 18 additions and 18 deletions

View file

@ -35,8 +35,8 @@
Modality Mode dynamics% Dynamics% make-syn make-asyn Modality Mode dynamics% Dynamics% make-syn make-asyn
make-asyn-dynamics make-syn-dynamics build-full-state-graph make-asyn-dynamics make-syn-dynamics build-full-state-graph
pretty-print-state pretty-print-state/boolean pretty-print-state-graph-with pretty-print-state pretty-print-state/01 pretty-print-state-graph-with
pretty-print-state-graph ppsg pretty-print-state-graph/boolean ppsgb pretty-print-state-graph ppsg pretty-print-state-graph/01 ppsg01
) )
(define-type (State a) (VariableMapping a)) (define-type (State a) (VariableMapping a))
@ -667,14 +667,14 @@
(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-state/boolean (All (a) (-> (State a) String))) (: pretty-print-state/01 (All (a) (-> (State a) String)))
(define (pretty-print-state/boolean s) (define (pretty-print-state/01 s)
(string-join (hash-map s (λ (key val) (format "~a:~a" key (any->01 val))) #t))) (string-join (hash-map s (λ (key val) (format "~a:~a" key (any->01 val))) #t)))
(module+ test (module+ test
(test-case "pretty-print-state/boolean" (test-case "pretty-print-state/01"
(check-equal? (check-equal?
(pretty-print-state/boolean (hash 'a #f 'b #t 'c #t)) (pretty-print-state/01 (hash 'a #f 'b #t 'c #t))
"a:0 b:1 c:1"))) "a:0 b:1 c:1")))
(: pretty-print-state-graph-with (-> Graph (-> Any Any) Graph)) (: pretty-print-state-graph-with (-> Graph (-> Any Any) Graph))
@ -694,13 +694,13 @@
(define ppsg pretty-print-state-graph) (define ppsg pretty-print-state-graph)
(: pretty-print-state-graph/boolean (-> Graph Graph)) (: pretty-print-state-graph/01 (-> Graph Graph))
(define (pretty-print-state-graph/boolean gr) (define (pretty-print-state-graph/01 gr)
(define (pprinter/any [x : Any]) (define (pprinter/any [x : Any])
(pretty-print-state/boolean (assert-type x (State Any)))) (pretty-print-state/01 (assert-type x (State Any))))
(pretty-print-state-graph-with gr pprinter/any)) (pretty-print-state-graph-with gr pprinter/any))
(define ppsgb pretty-print-state-graph/boolean) (define ppsg01 pretty-print-state-graph/01)
(: build-full-state-graph (All (a) (-> (Dynamics% a) Graph))) (: build-full-state-graph (All (a) (-> (Dynamics% a) Graph)))
(define (build-full-state-graph dyn) (define (build-full-state-graph dyn)
@ -722,7 +722,7 @@
(test-case "pretty-print-state-graph, pretty-print-state-graph/boolean" (test-case "pretty-print-state-graph, pretty-print-state-graph/boolean"
(check-equal? (graphviz (ppsg sg)) (check-equal? (graphviz (ppsg sg))
"digraph G {\n\tnode0 [label=\"x:#f y:#t z:#f\"];\n\tnode1 [label=\"x:#f y:#t z:#t\"];\n\tnode2 [label=\"x:#t y:#f z:#t\"];\n\tnode3 [label=\"x:#t y:#t z:#t\"];\n\tnode4 [label=\"x:#t y:#t z:#f\"];\n\tnode5 [label=\"x:#t y:#f z:#f\"];\n\tnode6 [label=\"x:#f y:#f z:#f\"];\n\tnode7 [label=\"x:#f y:#f z:#t\"];\n\tsubgraph U {\n\t\tedge [dir=none];\n\t}\n\tsubgraph D {\n\t\tnode0 -> node6 [];\n\t\tnode1 -> node7 [];\n\t\tnode2 -> node4 [];\n\t\tnode3 -> node1 [];\n\t\tnode4 -> node0 [];\n\t\tnode5 -> node4 [];\n\t\tnode6 -> node5 [];\n\t\tnode7 -> node5 [];\n\t}\n}\n") "digraph G {\n\tnode0 [label=\"x:#f y:#t z:#f\"];\n\tnode1 [label=\"x:#f y:#t z:#t\"];\n\tnode2 [label=\"x:#t y:#f z:#t\"];\n\tnode3 [label=\"x:#t y:#t z:#t\"];\n\tnode4 [label=\"x:#t y:#t z:#f\"];\n\tnode5 [label=\"x:#t y:#f z:#f\"];\n\tnode6 [label=\"x:#f y:#f z:#f\"];\n\tnode7 [label=\"x:#f y:#f z:#t\"];\n\tsubgraph U {\n\t\tedge [dir=none];\n\t}\n\tsubgraph D {\n\t\tnode0 -> node6 [];\n\t\tnode1 -> node7 [];\n\t\tnode2 -> node4 [];\n\t\tnode3 -> node1 [];\n\t\tnode4 -> node0 [];\n\t\tnode5 -> node4 [];\n\t\tnode6 -> node5 [];\n\t\tnode7 -> node5 [];\n\t}\n}\n")
(check-equal? (graphviz (ppsgb sg)) (check-equal? (graphviz (ppsg01 sg))
"digraph G {\n\tnode0 [label=\"x:1 y:0 z:0\"];\n\tnode1 [label=\"x:0 y:1 z:1\"];\n\tnode2 [label=\"x:0 y:0 z:1\"];\n\tnode3 [label=\"x:1 y:1 z:1\"];\n\tnode4 [label=\"x:1 y:0 z:1\"];\n\tnode5 [label=\"x:0 y:1 z:0\"];\n\tnode6 [label=\"x:0 y:0 z:0\"];\n\tnode7 [label=\"x:1 y:1 z:0\"];\n\tsubgraph U {\n\t\tedge [dir=none];\n\t}\n\tsubgraph D {\n\t\tnode0 -> node7 [];\n\t\tnode1 -> node2 [];\n\t\tnode2 -> node0 [];\n\t\tnode3 -> node1 [];\n\t\tnode4 -> node7 [];\n\t\tnode5 -> node6 [];\n\t\tnode6 -> node0 [];\n\t\tnode7 -> node5 [];\n\t}\n}\n")))) "digraph G {\n\tnode0 [label=\"x:1 y:0 z:0\"];\n\tnode1 [label=\"x:0 y:1 z:1\"];\n\tnode2 [label=\"x:0 y:0 z:1\"];\n\tnode3 [label=\"x:1 y:1 z:1\"];\n\tnode4 [label=\"x:1 y:0 z:1\"];\n\tnode5 [label=\"x:0 y:1 z:0\"];\n\tnode6 [label=\"x:0 y:0 z:0\"];\n\tnode7 [label=\"x:1 y:1 z:0\"];\n\tsubgraph U {\n\t\tedge [dir=none];\n\t}\n\tsubgraph D {\n\t\tnode0 -> node7 [];\n\t\tnode1 -> node2 [];\n\t\tnode2 -> node0 [];\n\t\tnode3 -> node1 [];\n\t\tnode4 -> node7 [];\n\t\tnode5 -> node6 [];\n\t\tnode6 -> node0 [];\n\t\tnode7 -> node5 [];\n\t}\n}\n"))))
) )

View file

@ -493,12 +493,12 @@ Pretty-prints a state of a network.
} }
@defproc[(pretty-print-state/boolean [s (State a)]) String]{ @defproc[(pretty-print-state/01 [s (State a)]) String]{
Pretty-prints a state of a network, replacing all @racket[#f] values with 0 and Pretty-prints a state of a network, replacing all @racket[#f] values with 0 and
all other values with 1. all other values with 1.
@ex[(pretty-print-state/boolean (hash 'a #f 'b 3 'c '() 'd #t))] @ex[(pretty-print-state/01 (hash 'a #f 'b 3 'c '() 'd #t))]
} }
@ -531,23 +531,23 @@ A shortcut for @racket[pretty-print-state-graph].
} }
@defproc[(pretty-print-state-graph/boolean [gr Graph]) Graph]{ @defproc[(pretty-print-state-graph/01 [gr Graph]) Graph]{
Calls @racket[pretty-print-state-graph-with] with @racket[pretty-print-state/boolean]. Calls @racket[pretty-print-state-graph-with] with @racket[pretty-print-state/01].
@ex[ @ex[
(let* ([n (forms->boolean-network (hash 'a '(and a b) (let* ([n (forms->boolean-network (hash 'a '(and a b)
'b '(not b)))] 'b '(not b)))]
[syn-dynamics (make-syn-dynamics n)]) [syn-dynamics (make-syn-dynamics n)])
(dotit (pretty-print-state-graph/boolean (dotit (pretty-print-state-graph/01
((inst build-full-state-graph Boolean) syn-dynamics)))) ((inst build-full-state-graph Boolean) syn-dynamics))))
] ]
} }
@defproc[(ppsgb [gr Graph]) Graph]{ @defproc[(ppsg01 [gr Graph]) Graph]{
A shortcut for @racket[pretty-print-state-graph/boolean]. A shortcut for @racket[pretty-print-state-graph/01].
} }