Add build-interactive-process/org.

This commit is contained in:
Sergiu Ivanov 2023-08-19 16:47:49 +02:00
parent 11c736b04b
commit a2e5f9d091
2 changed files with 40 additions and 0 deletions

21
rs.rkt
View File

@ -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")

View File

@ -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))
]}