From 07e1a73b50cf20df61d47e566efc7c637fd9ca1b Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Wed, 4 Mar 2020 18:54:36 +0100 Subject: [PATCH] networks: Add read-org-network-make-asyn and read-org-network-make-syn. Also add some shortcuts. --- networks.rkt | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/networks.rkt b/networks.rkt index 3b60fa3..d6103b6 100644 --- a/networks.rkt +++ b/networks.rkt @@ -39,6 +39,8 @@ [make-dynamics-from-func (-> network? (-> (listof variable?) mode?) dynamics?)] [make-asyn-dynamics (-> network? dynamics?)] [make-syn-dynamics (-> network? dynamics?)] + [read-org-network-make-asyn (-> string? dynamics?)] + [read-org-network-make-syn (-> string? dynamics?)] [dds-step-one (-> dynamics? state? (set/c state?))] [dds-step-one-annotated (-> dynamics? state? (set/c (cons/c modality? state?)))] [dds-step (-> dynamics? (set/c state? #:kind 'dont-care) (set/c state?))] @@ -67,7 +69,7 @@ [update-function/c contract?] [domain-mapping/c contract?]) ;; Syntax - st stb nn ppsg ppsgb) + st stb nn ppsg ppsgb unorg-syn unorg-asyn) ;;; ================= @@ -328,6 +330,20 @@ (define (make-syn-dynamics network) (make-dynamics-from-func network make-syn)) +;;; Reads an Org-mode-produced sexp, converts it into a network, and +;;; builds the asyncronous dynamics out of it. +(define read-org-network-make-asyn (compose make-asyn-dynamics network-form->network read-org-variable-mapping)) + +;;; A shortcut for read-org-network-make-asyn. +(define-syntax-rule (unorg-asyn str) (read-org-network-make-asyn str)) + +;;; Reads an Org-mode-produced sexp, converts it into a network, and +;;; builds the synchronous dynamics out of it. +(define read-org-network-make-syn (compose make-syn-dynamics network-form->network read-org-variable-mapping)) + +;;; A shortcut for read-org-network-make-syn. +(define-syntax-rule (unorg-syn str) (read-org-network-make-syn str)) + ;;; Pretty-prints a state of the network. (define (pretty-print-state s) (string-join (hash-map s (λ (key val) (format "~a:~a" key val)) #t)))