update-function-form->update-function → update-function-form->update-function/any

This commit is contained in:
Sergiu Ivanov 2022-05-03 21:26:36 +02:00
parent 320ae55456
commit 2c2d8fbbdb
2 changed files with 9 additions and 9 deletions

View File

@ -16,7 +16,7 @@
make-01-domains make-01-network update make-01-domains make-01-network update
UpdateFunctionForm (struct-out network-form) NetworkForm UpdateFunctionForm (struct-out network-form) NetworkForm
update-function-form->update-function update-function-form->update-function/any
) )
(define-type (State a) (VariableMapping a)) (define-type (State a) (VariableMapping a))
@ -125,14 +125,14 @@
#:transparent #:transparent
#:type-name NetworkForm) #:type-name NetworkForm)
(: update-function-form->update-function (-> UpdateFunctionForm (UpdateFunction Any))) (: update-function-form->update-function/any (-> UpdateFunctionForm (UpdateFunction Any)))
(define (update-function-form->update-function form) (define (update-function-form->update-function/any form)
(λ (s) (eval1-with s form))) (λ (s) (eval1-with s form)))
(module+ test (module+ test
(test-case "update-function-form->update-function" (test-case "update-function-form->update-function/any"
(define s (hash 'x #t 'y #f)) (define s (hash 'x #t 'y #f))
(define f (update-function-form->update-function '(and x y))) (define f (update-function-form->update-function/any '(and x y)))
(check-equal? (f s) #f))) (check-equal? (f s) #f)))
) )
@ -303,7 +303,7 @@
(define (network-form->network nf) (define (network-form->network nf)
(network (network
(for/hash ([(x form) (in-hash (network-form-forms nf))]) (for/hash ([(x form) (in-hash (network-form-forms nf))])
(values x (update-function-form->update-function form))) (values x (update-function-form->update-function/any form)))
(network-form-domains nf))) (network-form-domains nf)))
(module+ test (module+ test

View File

@ -232,13 +232,13 @@ The type of instances of @racket[network-form].
(hash 'a '(#f #t) 'b '(#f #t))) (hash 'a '(#f #t) 'b '(#f #t)))
]} ]}
@defproc[(update-function-form->update-function [func UpdateFunctionForm]) @defproc[(update-function-form->update-function/any [func UpdateFunctionForm])
(UpdateFunction Any)]{ (UpdateFunction Any)]{
Builds an update function from an update function form. Builds an update function from an update function form.
@ex[ @ex[
(define and-from-form (update-function-form->update-function '(and x y))) (define and-from-form (update-function-form->update-function/any '(and x y)))
(and-from-form (hash 'x #f 'y #f)) (and-from-form (hash 'x #f 'y #f))
(and-from-form (hash 'x #f 'y #t)) (and-from-form (hash 'x #f 'y #t))
(and-from-form (hash 'x #t 'y #f)) (and-from-form (hash 'x #t 'y #f))