From 6518ae2fdddc751a5a6a8200c3339cd9ee4e8a2f Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Tue, 8 Aug 2023 18:09:24 +0200 Subject: [PATCH] Add make-reaction. --- rs.rkt | 12 +++++++++++- scribblings/rs.scrbl | 12 ++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/rs.rkt b/rs.rkt index 954edf2..4165870 100644 --- a/rs.rkt +++ b/rs.rkt @@ -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") diff --git a/scribblings/rs.scrbl b/scribblings/rs.scrbl index c3ececc..b5e21d2 100644 --- a/scribblings/rs.scrbl +++ b/scribblings/rs.scrbl @@ -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