rs: Add unorg-rs and showcase it in example.org.

This commit is contained in:
Sergiu Ivanov 2020-03-01 20:26:16 +01:00
parent 02d5384674
commit d2121bd5e6
2 changed files with 26 additions and 1 deletions

View File

@ -467,6 +467,26 @@ tab
[[file:dots/examplehsuRqc.svg]]
:END:
** Reaction systems
:PROPERTIES:
:header-args:racket: :prologue "#lang racket\n(require graph (file \"~/Candies/prj/racket/dds/rs.rkt\") (file \"~/Candies/prj/racket/dds/utils.rkt\"))"
:END:
Consider the following reaction system:
#+NAME: rs1
| a | x t | y | z |
| b | x | q | z |
Here is how we read this reaction into Racket code:
#+BEGIN_SRC racket :results output drawer :var input-rs=munch-table(rs1)
(unorg-rs input-rs)
#+END_SRC
#+RESULTS:
:RESULTS:
(hash 'a (reaction (set 'x 't) (set 'y) (set 'z)) 'b (reaction (set 'x) (set 'q) (set 'z)))
:END:
* Local Variables :noexport:
# Local Variables:

7
rs.rkt
View File

@ -14,7 +14,9 @@
;; Type names
Species ReactionSystem
;; Functions
enabled? list-enabled union-products apply-rs ht-str-triples->rs)
enabled? list-enabled union-products apply-rs ht-str-triples->rs
;; Syntax
unorg-rs)
;;; =================
;;; Basic definitions
@ -95,3 +97,6 @@
(for/hash : ReactionSystem
([(a triple) (in-hash ht)])
(values a (str-triple->reaction triple))))
;;; Chains ht-str-triples->rs with unorg.
(define (unorg-rs str) (ht-str-triples->rs (unorg str)))