diff --git a/rs.rkt b/rs.rkt index c27df58..1fde21d 100644 --- a/rs.rkt +++ b/rs.rkt @@ -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") diff --git a/scribblings/rs.scrbl b/scribblings/rs.scrbl index 1d441e6..dccbfef 100644 --- a/scribblings/rs.scrbl +++ b/scribblings/rs.scrbl @@ -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)))) +]}