rs,union-products: Return an empty set when no reaction names are given.

This commit is contained in:
Sergiu Ivanov 2020-03-02 18:31:02 +01:00
parent 6427af17c8
commit 868988c966

11
rs.rkt
View File

@ -51,15 +51,18 @@
name))
;;; Returns the union of the product sets of the given reactions in a
;;; reaction system.
;;; reaction system. If no reactions are supplied, returns the empty
;;; set.
;;;
;;; This function can be seen as producing the result of the
;;; application of the given reactions to a set. Clearly, it does not
;;; check whether the reactions are actually enabled.
(define (union-products rs as)
(apply set-union
(for/list ([a as])
(reaction-products (hash-ref rs a)))))
(if (empty? as)
(set)
(apply set-union
(for/list ([a as])
(reaction-products (hash-ref rs a))))))
;;; Applies a reaction system to a set.
(define (apply-rs rs s)