Type tabulate-state*/boolean.
This commit is contained in:
parent
3d58660e9c
commit
fabecbe0f9
2 changed files with 35 additions and 1 deletions
20
networks.rkt
20
networks.rkt
|
@ -39,7 +39,7 @@
|
|||
pretty-print-state pretty-print-state/01 pretty-print-state-graph-with
|
||||
pretty-print-state-graph ppsg pretty-print-state-graph/01 ppsg01
|
||||
|
||||
tabulate-state*
|
||||
tabulate-state* tabulate-state*/boolean
|
||||
)
|
||||
|
||||
(define-type (State a) (VariableMapping a))
|
||||
|
@ -756,6 +756,24 @@
|
|||
(1 3 4 -2)
|
||||
(2 2 4 0)
|
||||
(2 3 5 -1)))))
|
||||
|
||||
(: tabulate-state*/boolean
|
||||
(-> (Listof (-> (State Boolean) Boolean)) (Listof Variable)
|
||||
(Listof (Listof Boolean))))
|
||||
(define (tabulate-state*/boolean funcs args)
|
||||
(tabulate-state* funcs (make-boolean-domains args)))
|
||||
|
||||
(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)))
|
||||
(check-equal? (tabulate-state*/boolean (list f1 f2) '(a b))
|
||||
'((#f #f #f #f)
|
||||
(#f #t #f #t)
|
||||
(#t #f #f #t)
|
||||
(#t #t #t #t)))))
|
||||
)
|
||||
|
||||
(require 'typed)
|
||||
|
|
|
@ -735,6 +735,22 @@ the states.
|
|||
(tabulate-state* (list f1 f2) (hash 'a '(1 2) 'b '(2 3))))
|
||||
]}
|
||||
|
||||
@defproc[(tabulate-state*/boolean [funcs (Listof (-> State Boolean) Boolean)]
|
||||
[args (Listof Variable)])
|
||||
(Listof (Listof Boolean))]{
|
||||
|
||||
Like @racket[tabulate-state*], but the functions operate on Boolean states.
|
||||
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)))
|
||||
]}
|
||||
|
||||
@section{Constructing functions and networks}
|
||||
|
||||
@section{Random functions and networks}
|
||||
|
|
Loading…
Reference in a new issue