Use define/:.
This commit is contained in:
parent
d7d9274bc9
commit
da368d2574
2 changed files with 11 additions and 19 deletions
12
networks.rkt
12
networks.rkt
|
@ -747,10 +747,8 @@
|
|||
|
||||
(module+ test
|
||||
(test-case "tabulate-state*"
|
||||
(define (f1 [st : (State Integer)])
|
||||
(auto-hash-ref/: st (+ :a :b)))
|
||||
(define (f2 [st : (State Integer)])
|
||||
(auto-hash-ref/: st (- :a :b)))
|
||||
(define/: f1 (State Integer) (+ :a :b))
|
||||
(define/: f2 (State Integer) (- :a :b))
|
||||
(check-equal? (tabulate-state* (list f1 f2) (hash 'a '(1 2) 'b '(2 3)))
|
||||
'((1 2 3 -1)
|
||||
(1 3 4 -2)
|
||||
|
@ -765,10 +763,8 @@
|
|||
|
||||
(module+ test
|
||||
(test-case "tabulate-state*/boolean"
|
||||
(define (f1 [st : (State Boolean)])
|
||||
(auto-hash-ref/: st (and :a :b)))
|
||||
(define (f2 [st : (State Boolean)])
|
||||
(auto-hash-ref/: st (or :a :b)))
|
||||
(define/: f1 (State Boolean) (and :a :b))
|
||||
(define/: f2 (State Boolean) (or :a :b))
|
||||
(check-equal? (tabulate-state*/boolean (list f1 f2) '(a b))
|
||||
'((#f #f #f #f)
|
||||
(#f #t #f #t)
|
||||
|
|
|
@ -727,12 +727,10 @@ functions. @racket[domains] defines the domains of each of the component of
|
|||
the states.
|
||||
|
||||
@ex[
|
||||
(require (only-in "utils.rkt" auto-hash-ref/:))
|
||||
(let ([f1 (λ ([st : (State Integer)])
|
||||
(auto-hash-ref/: st (+ :a :b)))]
|
||||
[f2 (λ ([st : (State Integer)])
|
||||
(auto-hash-ref/: st (- :a :b)))])
|
||||
(tabulate-state* (list f1 f2) (hash 'a '(1 2) 'b '(2 3))))
|
||||
(require (only-in "utils.rkt" λ/:))
|
||||
(tabulate-state* (list (λ/: (State Integer) (+ :a :b))
|
||||
(λ/: (State Integer) (- :a :b)))
|
||||
(hash 'a '(1 2) 'b '(2 3)))
|
||||
]}
|
||||
|
||||
@defproc[(tabulate-state*/boolean [funcs (Listof (-> State Boolean) Boolean)]
|
||||
|
@ -744,11 +742,9 @@ The list @racket[args] is used to generate all possible Boolean states
|
|||
containing the variables appearing on this list.
|
||||
|
||||
@ex[
|
||||
(let ([f1 (λ ([st : (State Boolean)])
|
||||
(auto-hash-ref/: st (and :a :b)))]
|
||||
[f2 (λ ([st : (State Boolean)])
|
||||
(auto-hash-ref/: st (or :a :b)))])
|
||||
(tabulate-state*/boolean (list f1 f2) '(a b)))
|
||||
(tabulate-state*/boolean (list (λ/: (State Boolean) (and :a :b))
|
||||
(λ/: (State Boolean) (or :a :b)))
|
||||
'(a b))
|
||||
]}
|
||||
|
||||
@section{Constructing functions and networks}
|
||||
|
|
Loading…
Reference in a new issue