networks: Add read-org-network-make-asyn and read-org-network-make-syn.

Also add some shortcuts.
This commit is contained in:
Sergiu Ivanov 2020-03-04 18:54:36 +01:00
parent f8dc65df0a
commit 07e1a73b50

View file

@ -39,6 +39,8 @@
[make-dynamics-from-func (-> network? (-> (listof variable?) mode?) dynamics?)] [make-dynamics-from-func (-> network? (-> (listof variable?) mode?) dynamics?)]
[make-asyn-dynamics (-> network? dynamics?)] [make-asyn-dynamics (-> network? dynamics?)]
[make-syn-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 (-> dynamics? state? (set/c state?))]
[dds-step-one-annotated (-> dynamics? state? (set/c (cons/c modality? 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?))] [dds-step (-> dynamics? (set/c state? #:kind 'dont-care) (set/c state?))]
@ -67,7 +69,7 @@
[update-function/c contract?] [update-function/c contract?]
[domain-mapping/c contract?]) [domain-mapping/c contract?])
;; Syntax ;; Syntax
st stb nn ppsg ppsgb) st stb nn ppsg ppsgb unorg-syn unorg-asyn)
;;; ================= ;;; =================
@ -328,6 +330,20 @@
(define (make-syn-dynamics network) (define (make-syn-dynamics network)
(make-dynamics-from-func network make-syn)) (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. ;;; Pretty-prints a state of the network.
(define (pretty-print-state s) (define (pretty-print-state s)
(string-join (hash-map s (λ (key val) (format "~a:~a" key val)) #t))) (string-join (hash-map s (λ (key val) (format "~a:~a" key val)) #t)))