From 320ae5545699656eafd6a8a524ff7f95d30c95aa Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Tue, 3 May 2022 00:37:13 +0200 Subject: [PATCH] Type update-function-form->update-function. --- networks.rkt | 24 ++++++++++++------------ scribblings/networks.scrbl | 14 ++++++++++++++ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/networks.rkt b/networks.rkt index 20b84d9..2c796d7 100644 --- a/networks.rkt +++ b/networks.rkt @@ -16,6 +16,7 @@ make-01-domains make-01-network update UpdateFunctionForm (struct-out network-form) NetworkForm + update-function-form->update-function ) (define-type (State a) (VariableMapping a)) @@ -123,6 +124,16 @@ [domains : (DomainMapping a)]) #:transparent #:type-name NetworkForm) + + (: update-function-form->update-function (-> UpdateFunctionForm (UpdateFunction Any))) + (define (update-function-form->update-function form) + (λ (s) (eval1-with s form))) + + (module+ test + (test-case "update-function-form->update-function" + (define s (hash 'x #t 'y #f)) + (define f (update-function-form->update-function '(and x y))) + (check-equal? (f s) #f))) ) (require 'typed) @@ -139,8 +150,7 @@ [struct dynamics ([network network?] [mode mode?])]) ;; Functions - (contract-out [update-function-form->update-function (-> update-function-form? update-function/c)] - [network-form->network (-> network-form? network?)] + (contract-out [network-form->network (-> network-form? network?)] [make-boolean-network-form (-> variable-mapping? network-form?)] [forms->boolean-network (-> variable-mapping? network?)] [list-syntactic-interactions (-> network-form? variable? (listof variable?))] @@ -289,16 +299,6 @@ (define update-function-form? any/c) -;;; Build an update function from an update function form. -(define (update-function-form->update-function form) - (λ (s) (eval1-with s form))) - -(module+ test - (test-case "update-function-form->update-function" - (define s (hash 'x #t 'y #f)) - (define f (update-function-form->update-function '(and x y))) - (check-equal? (f s) #f))) - ;;; Build a network from a network form. (define (network-form->network nf) (network diff --git a/scribblings/networks.scrbl b/scribblings/networks.scrbl index 678fab0..14ab119 100644 --- a/scribblings/networks.scrbl +++ b/scribblings/networks.scrbl @@ -232,6 +232,20 @@ The type of instances of @racket[network-form]. (hash 'a '(#f #t) 'b '(#f #t))) ]} +@defproc[(update-function-form->update-function [func UpdateFunctionForm]) + (UpdateFunction Any)]{ + +Builds an update function from an update function form. + +@ex[ +(define and-from-form (update-function-form->update-function '(and x y))) +(and-from-form (hash 'x #f 'y #f)) +(and-from-form (hash 'x #f 'y #t)) +(and-from-form (hash 'x #t 'y #f)) +(and-from-form (hash 'x #t 'y #t)) +]} + + @section{Inferring interaction graphs} This section provides inference of both unsigned and signed interaction graphs.