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.