Type read-org-rs.

This commit is contained in:
Sergiu Ivanov 2023-08-10 18:05:22 +02:00
parent aae2e1f964
commit 6a9adf5e07
2 changed files with 22 additions and 1 deletions

15
rs.rkt
View File

@ -7,7 +7,7 @@
Species (struct-out reaction) Reaction ReactionName ReactionSystem
make-reaction enabled? list-enabled union-products apply-rs
str-triple->reaction ht-str-triples->rs
str-triple->reaction ht-str-triples->rs read-org-rs
)
(module+ test
@ -120,6 +120,19 @@
'b (list "" "x y" "t j")))
(hash 'a (reaction (set 'y 'x) (set) (set 'k 'i))
'b (reaction (set) (set 'y 'x) (set 't 'j))))))
(: read-org-rs (-> String ReactionSystem))
(define (read-org-rs str)
(ht-str-triples->rs
(assert-type (read-org-variable-mapping str)
(Immutable-HashTable ReactionName (List String String String)))))
(module+ test
(test-case "read-org-rs"
(check-equal?
(read-org-rs "((\"a\" \"x t\" \"y\" \"z\") (\"b\" \"x\" \"q\" \"z\"))")
(hash 'a (reaction (set 't 'x) (set 'y) (set 'z))
'b (reaction (set 'x) (set 'q) (set 'z))))))
)
(require graph "utils.rkt" "generic.rkt")

View File

@ -148,6 +148,14 @@ a reaction system.
'b (list "" "x y" "t j")))
]}
@defproc[(read-org-rs [str String]) ReactionSystem]{
Reads a reaction system from an Org-mode style string.
@ex[
(read-org-rs "((\"a\" \"x t\" \"y\" \"z\") (\"b\" \"x\" \"q\" \"z\"))")
]}
@section{Dynamics of reaction systems}