diff --git a/rs.rkt b/rs.rkt index 9a41215..c27df58 100644 --- a/rs.rkt +++ b/rs.rkt @@ -13,6 +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 ) (module+ test @@ -306,6 +307,26 @@ (cons (set 'x) (set 'z)) (cons (set) (set 'z)) (cons (set) (set)))))) + + (: build-interactive-process/org (-> ReactionSystem (Listof (Setof Species)) + (Listof (Listof (Setof Species))))) + (define (build-interactive-process/org rs context) + (for/list : (Listof (Listof (Setof Species))) + ([p (build-interactive-process rs context)]) + (list (car p) (cdr p)))) + + (module+ test + (test-case "build-interactive-process/org" + (define rs (hash 'a (make-reaction '(x) '(y) '(z)) + 'b (make-reaction '(x y) '() '(x)))) + (define ctx : (Listof (Setof Species)) (list (set 'x 'y) (set) (set 'x) (set))) + (check-equal? (build-interactive-process/org rs ctx) + (list + (list (set 'y 'x) (set)) + (list (set) (set 'x)) + (list (set 'x) (set 'z)) + (list (set) (set 'z)) + (list (set) (set)))))) ) (require graph "utils.rkt" "generic.rkt") diff --git a/scribblings/rs.scrbl b/scribblings/rs.scrbl index 4ca8e63..1d441e6 100644 --- a/scribblings/rs.scrbl +++ b/scribblings/rs.scrbl @@ -328,3 +328,22 @@ the effect of the last context. [ctx : (Listof (Setof Species)) (list (set) (set) (set 'x))]) (build-interactive-process rs ctx)) ]} + +@defproc[(build-interactive-process/org + [rs ReactionSystem] + [ctx (Listof (Setof Species))]) + (Listof (Listof (Setof Species)))]{ + +Like @racket[build-interactive-process], but the type of a line of the +output is @racket[(Listof (Setof Species))] instead of @racket[(Pairof +(Setof Species) (Setof Species))]. + +This function may be more practical for outputting directly to an +Org-mode table. + +@ex[ +(let ([rs (hash 'a (make-reaction '(x) '(y) '(z)) + 'b (make-reaction '(x y) '() '(x)))] + [ctx : (Listof (Setof Species)) (list (set) (set) (set 'x))]) + (build-interactive-process/org rs ctx)) +]}