From e07c5c239c1037acebd718a14611debf0bf37273 Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Mon, 2 Mar 2020 18:36:26 +0100 Subject: [PATCH] example: munch-table -> munch-sexp. This code block can be used to prepare any sexp Org-mode produces. --- example/example.org | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/example/example.org b/example/example.org index c7a3eee..af37a90 100644 --- a/example/example.org +++ b/example/example.org @@ -8,7 +8,7 @@ The [[intro][following section]] describes how Org-mode can interact with Racket, and how this interaction can be used for a fluid workflow - with =dds=. In particular, the code block =munch-table= is [[tabread][defined]] + with =dds=. In particular, the code block =munch-sexp= is [[tabread][defined]] in this section. The subsequent sections show off some the functionalities of the @@ -204,19 +204,19 @@ tab parameterised Elisp source block which will explicitly convert the table to a string: - #+NAME: munch-table + #+NAME: munch-sexp #+BEGIN_SRC elisp :results output drawer :var tab=test-table (prin1 tab) #+END_SRC - #+RESULTS: munch-table + #+RESULTS: munch-sexp :RESULTS: (("a" "(and a b)") ("b" "(or b (not a))")) :END: We can now correctly receive this table in a Racket source code - block by threading it through =munch-table=: - #+BEGIN_SRC racket :results output drawer :var tab=munch-table(tab=test-table) + block by threading it through =munch-sexp=: + #+BEGIN_SRC racket :results output drawer :var tab=munch-sexp(tab=test-table) (println tab) #+END_SRC @@ -227,7 +227,7 @@ tab [[../utils.rkt][=dds/utils=]] has several functions for parsing such strings, and notably =read-org-variable-mapping=, with the shortcut =unorg=: - #+BEGIN_SRC racket :results output drawer :var tab=munch-table(tab=test-table) + #+BEGIN_SRC racket :results output drawer :var tab=munch-sexp(tab=test-table) (unorg tab) #+END_SRC @@ -236,7 +236,7 @@ tab '#hash((a . (and a b)) (b . (or b (not a)))) :END: - Of course, we can use =munch-table= to prepare any other table than + Of course, we can use =munch-sexp= to prepare any other table than =test-table= for use with Racket: #+NAME: another-test-table @@ -244,7 +244,7 @@ tab | b | (and a c) | | c | (and a (not b)) | - #+BEGIN_SRC racket :results output drawer :var tab=munch-table(tab=another-test-table) + #+BEGIN_SRC racket :results output drawer :var tab=munch-sexp(tab=another-test-table) (unorg tab) #+END_SRC @@ -256,7 +256,7 @@ tab ** Inline graph visualisation with Graphviz Some functions in =dds= build graphs: - #+BEGIN_SRC racket :results output drawer :var bf=munch-table(another-test-table) + #+BEGIN_SRC racket :results output drawer :var bf=munch-sexp(another-test-table) (build-interaction-graph (unorg bf)) #+END_SRC @@ -272,7 +272,7 @@ tab racket source code blocks takes care of requiring =graph=.) #+NAME: igraph - #+BEGIN_SRC racket :results output drawer :var bf=munch-table(another-test-table) + #+BEGIN_SRC racket :results output drawer :var bf=munch-sexp(another-test-table) (display (graphviz (build-interaction-graph (unorg bf)))) #+END_SRC @@ -327,7 +327,7 @@ tab Here's the unsigned interaction graph of this network: #+NAME: simple-bn-ig - #+BEGIN_SRC racket :results silent :var simple-bn=munch-table(simple-bn) + #+BEGIN_SRC racket :results silent :var simple-bn=munch-sexp(simple-bn) (dotit (build-interaction-graph (unorg simple-bn))) #+END_SRC @@ -343,7 +343,7 @@ tab Here's the signed interaction graph of this network: #+NAME: simple-bn-sig - #+BEGIN_SRC racket :results silent :var simple-bn=munch-table(simple-bn) + #+BEGIN_SRC racket :results silent :var simple-bn=munch-sexp(simple-bn) (dotit (build-boolean-signed-interaction-graph (unorg simple-bn))) #+END_SRC @@ -364,7 +364,7 @@ tab Here is the full state graph of this network under the asynchronous dynamics: #+NAME: simple-bn-sg - #+BEGIN_SRC racket :results silent :var simple-bn=munch-table(simple-bn) + #+BEGIN_SRC racket :results silent :var simple-bn=munch-sexp(simple-bn) (let* ([bn (nn (unorg simple-bn))] [bn-asyn (make-asyn-dynamics bn)]) (dotit (ppsg (build-full-boolean-state-graph bn-asyn)))) @@ -383,7 +383,7 @@ tab Alternatively, you may prefer a slighty more compact representation of Boolean values as 0 and 1: #+NAME: simple-bn-sg-bool - #+BEGIN_SRC racket :results silent :var simple-bn=munch-table(simple-bn) + #+BEGIN_SRC racket :results silent :var simple-bn=munch-sexp(simple-bn) (let* ([bn (nn (unorg simple-bn))] [bn-asyn (make-asyn-dynamics bn)]) (dotit (ppsgb (build-full-boolean-state-graph bn-asyn)))) @@ -409,8 +409,8 @@ tab These are the states which can be reached from it in at most 2 steps: #+NAME: simple-bn-some-state - #+HEADER: :var simple-bn=munch-table(simple-bn) - #+HEADER: :var some-state=munch-table(some-state) + #+HEADER: :var simple-bn=munch-sexp(simple-bn) + #+HEADER: :var some-state=munch-sexp(some-state) #+BEGIN_SRC racket :results silent (let* ([bn (nn (unorg simple-bn))] [bn-asyn (make-asyn-dynamics bn)] @@ -430,7 +430,7 @@ tab Here is the complete state graph with edges annotated with the modality leading to the update. #+NAME: simple-bn-sg-bool-ann - #+BEGIN_SRC racket :results silent :var simple-bn=munch-table(simple-bn) + #+BEGIN_SRC racket :results silent :var simple-bn=munch-sexp(simple-bn) (let* ([bn (nn (unorg simple-bn))] [bn-asyn (make-asyn-dynamics bn)]) (dotit (ppsgb (build-full-boolean-state-graph-annotated bn-asyn)))) @@ -452,7 +452,7 @@ tab | b | b | #+NAME: bn2-sgr - #+BEGIN_SRC racket :results silent :var input-bn=munch-table(bn2) + #+BEGIN_SRC racket :results silent :var input-bn=munch-sexp(bn2) (let* ([bn (nn (unorg input-bn))] [bn-asyn (make-asyn-dynamics bn)]) (dotit (ppsgb (build-full-boolean-state-graph-annotated bn-asyn)))) @@ -478,7 +478,7 @@ tab Here is how we read this reaction into Racket code: - #+BEGIN_SRC racket :results output drawer :var input-rs=munch-table(rs1) + #+BEGIN_SRC racket :results output drawer :var input-rs=munch-sexp(rs1) (unorg-rs input-rs) #+END_SRC @@ -488,7 +488,7 @@ tab :END: Here is how we can put it back into an Org-mode table: - #+BEGIN_SRC racket :results table drawer :var input-rs=munch-table(rs1) + #+BEGIN_SRC racket :results table drawer :var input-rs=munch-sexp(rs1) (org-rs (unorg-rs input-rs)) #+END_SRC @@ -499,7 +499,7 @@ tab :END: Here is how we can apply this reaction system to a state: - #+BEGIN_SRC racket :results output drawer :var input-rs=munch-table(rs1) + #+BEGIN_SRC racket :results output drawer :var input-rs=munch-sexp(rs1) (let ([rs (unorg-rs input-rs)]) (apply-rs rs (set 'x 't))) #+END_SRC @@ -510,7 +510,7 @@ tab :END: Let's see which reactions got applied: - #+BEGIN_SRC racket :results list :var input-rs=munch-table(rs1) + #+BEGIN_SRC racket :results list :var input-rs=munch-sexp(rs1) (let ([rs (unorg-rs input-rs)]) (list-enabled rs (set 'x 't))) #+END_SRC