From 868988c966f9fbff65b7a712ad49e764bffe17e1 Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Mon, 2 Mar 2020 18:31:02 +0100 Subject: [PATCH] rs,union-products: Return an empty set when no reaction names are given. --- rs.rkt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rs.rkt b/rs.rkt index afa3558..d2db293 100644 --- a/rs.rkt +++ b/rs.rkt @@ -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)