From 848142aa61e3b76eac21ee6f4aff4621b9f785b0 Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Wed, 14 Oct 2020 00:20:34 +0200 Subject: [PATCH] example: Explain new SBF-related additions. --- example/example.org | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/example/example.org b/example/example.org index f611355..c3b6153 100644 --- a/example/example.org +++ b/example/example.org @@ -971,6 +971,54 @@ tab | 1 | 1 | 1 | 0 | :end: + =dds= also includes functions for dealing with SBF operating on + states. In particular, to create an SBF, you can do: + + #+BEGIN_SRC racket :results output drawer +(make-sbf/state '((a . -1) (b . 1))) + #+END_SRC + + #+RESULTS: + :results: + (tbf/state '#hash((a . -1) (b . 1)) 0) + :end: + + Most of the functions operating on TBF can be directly applied to + SBF and therefore have no specialization for this particular case. + However, there are variants of reading and printing functions for + SBF. + + Consider the following table giving the weights of two SBF: + + #+NAME: simple-sbfs/state + | a | b | + | 1 | 1 | + | -2 | 1 | + + You can read these SBFs in the following way: + + #+BEGIN_SRC racket :results output drawer :var simple-sbfs/state=munch-sexp(simple-sbfs/state) +(read-org-sbfs/state simple-sbfs/state) + #+END_SRC + + #+RESULTS: + :results: + (list (tbf/state '#hash((a . 1) (b . 1)) 0) (tbf/state '#hash((a . -2) (b . 1)) 0)) + :end: + + You can print them back to an Org-mode table as follows: + + #+BEGIN_SRC racket :results table drawer :var simple-sbfs/state=munch-sexp(simple-sbfs/state) +(print-org-sbfs/state (read-org-sbfs/state simple-sbfs/state)) + #+END_SRC + + #+RESULTS: + :results: + | a | b | + | 1 | 1 | + | -2 | 1 | + :end: + * Reaction systems :PROPERTIES: :header-args:racket: :prologue "#lang racket\n(require graph dds/rs dds/utils)"