diff --git a/example/example.org b/example/example.org index 8c3c4a7..4424757 100644 --- a/example/example.org +++ b/example/example.org @@ -876,6 +876,65 @@ tab (list (tbf '#(1 -1) 0) (tbf '#(2 2) 0)) :END: +** Threshold Boolean networks (TBN) <> + =dds= includes a number of useful definitions for working with + threshold Boolean networks: networks of threshold Boolean + functions. Since, standalone TBF do give names to their inputs, + =dds= also defines TBF operating on states: + + #+BEGIN_SRC racket :results output drawer +(make-tbf/state '((a . 1) (b . 1)) 1) + #+END_SRC + + #+RESULTS: + :results: + (tbf/state '#hash((a . 1) (b . 1)) 1) + :end: + + As the example standalone TBF, this TBF only returns 1 when both + inputs are activated: + #+BEGIN_SRC racket :results output drawer +(apply-tbf/state (make-tbf/state '((a . 1) (b . 1)) 1) + (make-state '((a . 1) (b . 1)))) + #+END_SRC + + #+RESULTS: + :results: + 1 + :end: + + Here's how you can read this TBF from an Org-mode table: + #+NAME: simple-tbf/state + | a | b | f | + | 1 | 1 | 1 | + + #+BEGIN_SRC racket :results output drawer :var simple-tbf/state=munch-sexp(simple-tbf/state) +(read-org-tbfs/state simple-tbf/state) + #+END_SRC + + #+RESULTS: + :results: + (list (tbf/state '#hash((a . 1) (b . 1)) 1)) + :end: + + Note that the header of the rightmost column is discarded. + + =read-org-tbfs/state= can also read multiple TBFs at once: + + #+NAME: simple-tbfs/state + | a | b | f | + | 1 | 1 | 1 | + | -2 | 1 | 0 | + + #+BEGIN_SRC racket :results output drawer :var simple-tbfs/state=munch-sexp(simple-tbfs/state) +(read-org-tbfs/state simple-tbfs/state) + #+END_SRC + + #+RESULTS: + :results: + (list (tbf/state '#hash((a . 1) (b . 1)) 1) (tbf/state '#hash((a . -2) (b . 1)) 0)) + :end: + * Reaction systems :PROPERTIES: :header-args:racket: :prologue "#lang racket\n(require graph dds/rs dds/utils)"