From da368d25748fbf7ef22a14ab5e888cc6106d2109 Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Sun, 6 Nov 2022 22:48:30 +0100 Subject: [PATCH] Use define/:. --- networks.rkt | 12 ++++-------- scribblings/networks.scrbl | 18 +++++++----------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/networks.rkt b/networks.rkt index 3617d83..77aed68 100644 --- a/networks.rkt +++ b/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) diff --git a/scribblings/networks.scrbl b/scribblings/networks.scrbl index 35c0eff..e799c08 100644 --- a/scribblings/networks.scrbl +++ b/scribblings/networks.scrbl @@ -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}