rs: Add read-org-rs and define unorg-rs as a synonym for it.
This commit is contained in:
parent
7f214266d0
commit
4c6f3af2a9
2 changed files with 13 additions and 3 deletions
|
@ -24,7 +24,13 @@
|
||||||
(check-equal? (read-context-sequence "((\"x y\") (\"z\") (\"\") (\"t\"))")
|
(check-equal? (read-context-sequence "((\"x y\") (\"z\") (\"\") (\"t\"))")
|
||||||
(list (set 'x 'y) (set 'z) (set) (set 't)))
|
(list (set 'x 'y) (set 'z) (set) (set 't)))
|
||||||
(check-equal? (rs->ht-str-triples (make-immutable-hash (list (cons 'a (reaction (set 'x 't) (set 'y) (set 'z))))))
|
(check-equal? (rs->ht-str-triples (make-immutable-hash (list (cons 'a (reaction (set 'x 't) (set 'y) (set 'z))))))
|
||||||
#hash((a . ("t x" "y" "z")))))
|
#hash((a . ("t x" "y" "z"))))
|
||||||
|
(check-equal? (read-org-rs "((\"a\" \"x t\" \"y\" \"z\") (\"b\" \"x\" \"q\" \"z\"))")
|
||||||
|
(hash
|
||||||
|
'a
|
||||||
|
(reaction (set 'x 't) (set 'y) (set 'z))
|
||||||
|
'b
|
||||||
|
(reaction (set 'x) (set 'q) (set 'z)))))
|
||||||
|
|
||||||
(test-case "Dynamics of reaction systems"
|
(test-case "Dynamics of reaction systems"
|
||||||
(let* ([r1 (reaction (set 'x) (set 'y) (set 'z))]
|
(let* ([r1 (reaction (set 'x) (set 'y) (set 'z))]
|
||||||
|
|
8
rs.rkt
8
rs.rkt
|
@ -17,6 +17,7 @@
|
||||||
[union-products (-> reaction-system/c (listof symbol?) (set/c species?))]
|
[union-products (-> reaction-system/c (listof symbol?) (set/c species?))]
|
||||||
[apply-rs (-> reaction-system/c (set/c species?) (set/c species?))]
|
[apply-rs (-> reaction-system/c (set/c species?) (set/c species?))]
|
||||||
[ht-str-triples->rs (-> (hash/c symbol? (list/c string? string? string?)) reaction-system/c)]
|
[ht-str-triples->rs (-> (hash/c symbol? (list/c string? string? string?)) reaction-system/c)]
|
||||||
|
[read-org-rs (-> string? reaction-system/c)]
|
||||||
[read-context-sequence (-> string? (listof (set/c species?)))]
|
[read-context-sequence (-> string? (listof (set/c species?)))]
|
||||||
[rs->ht-str-triples (-> reaction-system/c (hash/c symbol? (list/c string? string? string?)))]
|
[rs->ht-str-triples (-> reaction-system/c (hash/c symbol? (list/c string? string? string?)))]
|
||||||
[dds-step-one (-> dynamics? state? (set/c state?))]
|
[dds-step-one (-> dynamics? state? (set/c state?))]
|
||||||
|
@ -103,8 +104,11 @@
|
||||||
(for/hash ([(a triple) (in-hash ht)])
|
(for/hash ([(a triple) (in-hash ht)])
|
||||||
(values a (str-triple->reaction triple))))
|
(values a (str-triple->reaction triple))))
|
||||||
|
|
||||||
;;; Chains ht-str-triples->rs with read-org-variable-mapping.
|
;;; Reads a reaction system from an Org-mode style string.
|
||||||
(define-syntax-rule (unorg-rs str) (ht-str-triples->rs (read-org-variable-mapping str)))
|
(define read-org-rs (compose ht-str-triples->rs read-org-variable-mapping))
|
||||||
|
|
||||||
|
;;; A synonym for read-org-rs.
|
||||||
|
(define-syntax-rule (unorg-rs str) (read-org-rs str))
|
||||||
|
|
||||||
;;; Reads a context sequence from an Org sexp corresponding to a list.
|
;;; Reads a context sequence from an Org sexp corresponding to a list.
|
||||||
(define (read-context-sequence str)
|
(define (read-context-sequence str)
|
||||||
|
|
Loading…
Reference in a new issue