rs: Add pretty-print-state and use it in update-graph.

This commit is contained in:
Sergiu Ivanov 2020-03-03 00:25:06 +01:00
parent f22d42f98c
commit cf99c8acf3

8
rs.rkt
View file

@ -173,9 +173,15 @@
(dds-build-state-graph-annotated (dynamics rs) (dds-build-state-graph-annotated (dynamics rs)
(set (state (set) contexts)))) (set (state (set) contexts))))
;;; Pretty-prints the context and the current result of a state of the
;;; reaction system.
(define/match (pretty-print-state st)
[((state res ctx))
(format "C:~a\nD:{~a}" (pretty-print-set-sets ctx) (pretty-print-set res))])
;;; Pretty prints the state graph of a reaction system. ;;; Pretty prints the state graph of a reaction system.
(define (pretty-print-state-graph sgr) (define (pretty-print-state-graph sgr)
(update-graph sgr #:e-func pretty-print-set-sets)) (update-graph sgr #:v-func pretty-print-state #:e-func pretty-print-set-sets))
;;; A shortcut for pretty-print-state-graph. ;;; A shortcut for pretty-print-state-graph.
(define-syntax-rule (ppsg sgr) (pretty-print-state-graph sgr)) (define-syntax-rule (ppsg sgr) (pretty-print-state-graph sgr))