diff --git a/rs-tests.rkt b/rs-tests.rkt index d7347e9..b185221 100644 --- a/rs-tests.rkt +++ b/rs-tests.rkt @@ -14,4 +14,6 @@ (check-false (enabled? r1 s2)) (check-equal? (list-enabled rs s1) '(a b)) (check-equal? (list-enabled rs s2) '(b)) - (check-equal? (union-products rs '(a b)) (set 'y 'z)))) + (check-equal? (union-products rs '(a b)) (set 'y 'z)) + (check-equal? (apply-rs rs s1) (set 'y 'z)) + (check-equal? (apply-rs rs s2) (set 'y)))) diff --git a/rs.rkt b/rs.rkt index 8bb6c39..23a78d7 100644 --- a/rs.rkt +++ b/rs.rkt @@ -10,7 +10,7 @@ ;; Type names Species ReactionSystem ;; Functions - enabled? list-enabled union-products) + enabled? list-enabled union-products apply-rs) ;;; ================= ;;; Basic definitions @@ -55,3 +55,9 @@ ((inst set Species)) ; set-union requires at least one argument (for/list : (Listof (Setof Species)) ([a as]) (reaction-products (hash-ref rs a))))) + +;;; Applies a reaction system to a set. +(: apply-rs (-> ReactionSystem (Setof Species) (Setof Species))) +(define (apply-rs rs s) + (let ([as (list-enabled rs s)]) + (union-products rs as)))