From a34b08e477be08bd8fdc3b6d81ce203c25ad5fa4 Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Tue, 2 Jun 2020 21:29:00 +0200 Subject: [PATCH] networks: Rewrite tabulate-state to use tabulate-state*. --- networks.rkt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/networks.rkt b/networks.rkt index 1f7524e..ed0c9f4 100644 --- a/networks.rkt +++ b/networks.rkt @@ -715,13 +715,12 @@ ;;; a listing the names of the variables of the domain and ending with ;;; the symbol 'f, which indicates the values of the function. (define (tabulate-state func domains #:headers [headers #t]) - (define (st-vals st) (hash-map st (λ (x y) y) #t)) - (define tab (for/list ([st (build-all-states domains)]) - (append (st-vals st) (list (func st))))) + (define tab (tabulate-state* `(,func) domains #:headers headers)) (cond [headers - (define vars (append (hash-map domains (λ (x y) x) #t) '(f))) - (cons vars tab)] + ;; Replace 'f1 in the headers by 'f. + (match tab [(cons hdrs vals) + (cons (append (drop-right hdrs 1) '(f)) vals)])] [else tab])) ;;; Like tabulate-state, but assumes the function is a Boolean