rs: Add read-context-sequence.
This commit is contained in:
parent
42b7dce359
commit
171147ad5e
2 changed files with 7 additions and 0 deletions
|
@ -21,6 +21,8 @@
|
|||
(test-case "Org-mode interaction"
|
||||
(check-equal? (ht-str-triples->rs #hash((a . ("x t" "y" "z"))))
|
||||
(make-immutable-hash (list (cons 'a (reaction (set 'x 't) (set 'y) (set 'z))))))
|
||||
(check-equal? (read-context-sequence "((\"x y\") (\"z\") (\"\") (\"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))))))
|
||||
#hash((a . ("t x" "y" "z")))))
|
||||
|
||||
|
|
5
rs.rkt
5
rs.rkt
|
@ -17,6 +17,7 @@
|
|||
[union-products (-> reaction-system/c (listof symbol?) (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)]
|
||||
[read-context-sequence (-> string? (listof (set/c species?)))]
|
||||
[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-annotated (-> dynamics? state? (set/c (cons/c (set/c symbol?) state?)))]
|
||||
|
@ -102,6 +103,10 @@
|
|||
;;; Chains ht-str-triples->rs with unorg.
|
||||
(define-syntax-rule (unorg-rs str) (ht-str-triples->rs (unorg str)))
|
||||
|
||||
;;; Reads a context sequence from an Org sexp corresponding to a list.
|
||||
(define (read-context-sequence str)
|
||||
(map (compose list->set read-symbol-list) (flatten (read-org-sexp str))))
|
||||
|
||||
;;; Removes the first and the last symbol of a given string.
|
||||
(define (drop-first-last str)
|
||||
(substring str 1 (- (string-length str) 1)))
|
||||
|
|
Loading…
Reference in a new issue