rs: Add apply-rs.
This commit is contained in:
parent
86256cd47e
commit
5c13b468e3
2 changed files with 10 additions and 2 deletions
|
@ -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))))
|
||||
|
|
8
rs.rkt
8
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)))
|
||||
|
|
Loading…
Reference in a new issue