Add make-reaction.

This commit is contained in:
Sergiu Ivanov 2023-08-08 18:09:24 +02:00
parent 6cf1505a61
commit 6518ae2fdd
2 changed files with 23 additions and 1 deletions

12
rs.rkt
View file

@ -4,7 +4,8 @@
(require typed/graph "utils.rkt" "dynamics.rkt")
(provide
Species (struct-out reaction) Reaction)
Species (struct-out reaction) Reaction
make-reaction)
(module+ test
(require typed/rackunit))
@ -16,6 +17,15 @@
[products : (Setof Species)])
#:transparent
#:type-name Reaction)
(: make-reaction (-> (Listof Species) (Listof Species) (Listof Species) Reaction))
(define (make-reaction r i p) (reaction (list->set r)
(list->set i)
(list->set p)))
(module+ test
(test-case "make-reaction"
(check-equal? (make-reaction '(a b) '(c d) '(e f))
(reaction (set 'b 'a) (set 'c 'd) (set 'f 'e)))))
)
(require graph "utils.rkt" "generic.rkt")

View file

@ -47,6 +47,18 @@ The type of the instances of @racket[reaction].
}
@defproc[(make-reaction [r (Listof Reaction)]
[i (Listof Reaction)]
[p (Listof Reaction)])
Reaction]{
A shortcut for constructing @racket[Reaction]s using list syntax
instead of set syntax.
@ex[
(make-reaction '(a b) '(c d) '(e f))
]}
@section{Org-mode interaction}
This section contains some useful primitives for