Add state and State.

This commit is contained in:
Sergiu Ivanov 2023-08-14 14:47:09 +02:00
parent f398d10d15
commit 78e88840cc
2 changed files with 27 additions and 0 deletions

7
rs.rkt
View file

@ -9,6 +9,8 @@
str-triple->reaction ht-str-triples->rs read-org-rs read-context-sequence
reaction->str-triple rs->ht-str-triples
(struct-out state) State
)
(module+ test
@ -167,6 +169,11 @@
(define rs (hash 'a (make-reaction '(x) '(y) '(z))
'b (make-reaction '(x y) '() '(t))))
(rs->ht-str-triples rs)))
(struct state ([result : (Setof Species)]
[rest-contexts : (Listof (Setof Species))])
#:transparent
#:type-name State)
)
(require graph "utils.rkt" "generic.rkt")

View file

@ -194,3 +194,23 @@ system starts with the initial context. Then, at every step, the result of
applying the reaction system is merged with the next element of the context
sequence, and the reaction system is then applied to the result of the union.
If the sequence of contexts is empty, the reaction system cannot evolve.
@defstruct*[state ([result (Setof Species)]
[rest-contexts (Listof (Setof Species))])]{
A state of a reaction system is a set of species representing the
result of the application of the reactions from the previous steps
(the field @racket[result]), plus the rest of the context sequence
(the field @racket[rest-contexts]).
The length of @racket[rest-contexts] dictates for how many steps the
reaction system will be run. If it is empty, no more reactions will
be applied.
}
@deftype[State]{
The type of the instances of @racket[state].
}