Type rs->ht-str-triples.

This commit is contained in:
Sergiu Ivanov 2023-08-14 13:32:27 +02:00
parent a469eae764
commit f398d10d15
2 changed files with 24 additions and 1 deletions

14
rs.rkt
View File

@ -8,7 +8,7 @@
make-reaction enabled? list-enabled union-products apply-rs
str-triple->reaction ht-str-triples->rs read-org-rs read-context-sequence
reaction->str-triple
reaction->str-triple rs->ht-str-triples
)
(module+ test
@ -155,6 +155,18 @@
(test-case "reaction->str-triple"
(check-equal? (reaction->str-triple (make-reaction '(x y) '(z t) '(k i)))
'("x y" "z t" "i k"))))
(: rs->ht-str-triples (-> ReactionSystem (HashTable ReactionName (Listof String))))
(define (rs->ht-str-triples rs)
(for/hash : (HashTable ReactionName (Listof String))
([(a r) (in-hash rs)])
(values a (reaction->str-triple r))))
(module+ test
(test-case "rs->ht-str-triples"
(define rs (hash 'a (make-reaction '(x) '(y) '(z))
'b (make-reaction '(x y) '() '(t))))
(rs->ht-str-triples rs)))
)
(require graph "utils.rkt" "generic.rkt")

View File

@ -173,6 +173,17 @@ Converts a reaction to a triple of strings.
(reaction->str-triple (make-reaction '(x y) '(z t) '(k i)))
]}
@defproc[(rs->ht-str-triples [rs ReactionSystem])
(HashTable ReactionName (Listof String))]{
Converts a reaction system to a hash table mapping
@racket[ReactionNames]s to triples of strings.
@ex[
(rs->ht-str-triples (hash 'a (make-reaction '(x) '(y) '(z))
'b (make-reaction '(x y) '() '(z))))
]}
@section{Dynamics of reaction systems}