Type pretty-print-state.

This commit is contained in:
Sergiu Ivanov 2023-08-23 16:37:54 +02:00
parent a2e5f9d091
commit 1e9d906b34
2 changed files with 21 additions and 1 deletions

13
rs.rkt
View file

@ -13,7 +13,7 @@
(struct-out state) State dynamics% Dynamics% build-interactive-process-graph
build-interactive-process-graph/simple-states
pretty-print-state-graph/simple-states build-interactive-process
build-interactive-process/org
build-interactive-process/org pretty-print-state
)
(module+ test
@ -327,6 +327,17 @@
(list (set 'x) (set 'z))
(list (set) (set 'z))
(list (set) (set))))))
(: pretty-print-state (-> State String))
(define/match (pretty-print-state st)
[((state res ctx))
(format "C:~a\nD:{~a}" (pretty-print-set-sets ctx) (pretty-print-set res))])
(module+ test
(test-case "pretty-print-state"
(check-equal? (pretty-print-state
(state (set 'x 'y) (list (set 'z) (set) (set 'x))))
"C:{z}{}{x}\nD:{x y}")))
)
(require graph "utils.rkt" "generic.rkt")

View file

@ -347,3 +347,12 @@ Org-mode table.
[ctx : (Listof (Setof Species)) (list (set) (set) (set 'x))])
(build-interactive-process/org rs ctx))
]}
@defproc[(pretty-print-state [st State]) String]{
Pretty prints the context sequence and the current result of
@racket[st].
@ex[
(pretty-print-state (state (set 'x 'y) (list (set 'z) (set) (set 'x))))
]}