Add state and State.
This commit is contained in:
parent
f398d10d15
commit
78e88840cc
2 changed files with 27 additions and 0 deletions
7
rs.rkt
7
rs.rkt
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
str-triple->reaction ht-str-triples->rs read-org-rs read-context-sequence
|
str-triple->reaction ht-str-triples->rs read-org-rs read-context-sequence
|
||||||
reaction->str-triple rs->ht-str-triples
|
reaction->str-triple rs->ht-str-triples
|
||||||
|
|
||||||
|
(struct-out state) State
|
||||||
)
|
)
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
|
@ -167,6 +169,11 @@
|
||||||
(define rs (hash 'a (make-reaction '(x) '(y) '(z))
|
(define rs (hash 'a (make-reaction '(x) '(y) '(z))
|
||||||
'b (make-reaction '(x y) '() '(t))))
|
'b (make-reaction '(x y) '() '(t))))
|
||||||
(rs->ht-str-triples rs)))
|
(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")
|
(require graph "utils.rkt" "generic.rkt")
|
||||||
|
|
|
@ -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
|
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.
|
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.
|
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].
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue