Use define/:.

This commit is contained in:
Sergiu Ivanov 2022-11-06 22:48:30 +01:00
parent d7d9274bc9
commit da368d2574
2 changed files with 11 additions and 19 deletions

View File

@ -747,10 +747,8 @@
(module+ test (module+ test
(test-case "tabulate-state*" (test-case "tabulate-state*"
(define (f1 [st : (State Integer)]) (define/: f1 (State Integer) (+ :a :b))
(auto-hash-ref/: st (+ :a :b))) (define/: f2 (State Integer) (- :a :b))
(define (f2 [st : (State Integer)])
(auto-hash-ref/: st (- :a :b)))
(check-equal? (tabulate-state* (list f1 f2) (hash 'a '(1 2) 'b '(2 3))) (check-equal? (tabulate-state* (list f1 f2) (hash 'a '(1 2) 'b '(2 3)))
'((1 2 3 -1) '((1 2 3 -1)
(1 3 4 -2) (1 3 4 -2)
@ -765,10 +763,8 @@
(module+ test (module+ test
(test-case "tabulate-state*/boolean" (test-case "tabulate-state*/boolean"
(define (f1 [st : (State Boolean)]) (define/: f1 (State Boolean) (and :a :b))
(auto-hash-ref/: st (and :a :b))) (define/: f2 (State Boolean) (or :a :b))
(define (f2 [st : (State Boolean)])
(auto-hash-ref/: st (or :a :b)))
(check-equal? (tabulate-state*/boolean (list f1 f2) '(a b)) (check-equal? (tabulate-state*/boolean (list f1 f2) '(a b))
'((#f #f #f #f) '((#f #f #f #f)
(#f #t #f #t) (#f #t #f #t)

View File

@ -727,12 +727,10 @@ functions. @racket[domains] defines the domains of each of the component of
the states. the states.
@ex[ @ex[
(require (only-in "utils.rkt" auto-hash-ref/:)) (require (only-in "utils.rkt" λ/:))
(let ([f1 (λ ([st : (State Integer)]) (tabulate-state* (list (λ/: (State Integer) (+ :a :b))
(auto-hash-ref/: st (+ :a :b)))] (λ/: (State Integer) (- :a :b)))
[f2 (λ ([st : (State Integer)]) (hash 'a '(1 2) 'b '(2 3)))
(auto-hash-ref/: st (- :a :b)))])
(tabulate-state* (list f1 f2) (hash 'a '(1 2) 'b '(2 3))))
]} ]}
@defproc[(tabulate-state*/boolean [funcs (Listof (-> State Boolean) Boolean)] @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. containing the variables appearing on this list.
@ex[ @ex[
(let ([f1 (λ ([st : (State Boolean)]) (tabulate-state*/boolean (list (λ/: (State Boolean) (and :a :b))
(auto-hash-ref/: st (and :a :b)))] (λ/: (State Boolean) (or :a :b)))
[f2 (λ ([st : (State Boolean)]) '(a b))
(auto-hash-ref/: st (or :a :b)))])
(tabulate-state*/boolean (list f1 f2) '(a b)))
]} ]}
@section{Constructing functions and networks} @section{Constructing functions and networks}