From 78386dd5bfed918d56051947c08c420268101278 Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Sun, 31 May 2020 23:31:54 +0200 Subject: [PATCH] functions: Add tabulate*/boolean. --- functions.rkt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/functions.rkt b/functions.rkt index 3a0d684..45d155b 100644 --- a/functions.rkt +++ b/functions.rkt @@ -15,6 +15,7 @@ [tabulate (-> procedure? (listof generic-set?) (listof list?))] [tabulate* (-> (listof procedure?) (listof generic-set?) (listof list?))] [tabulate/boolean (-> procedure-fixed-arity? (listof (listof boolean?)))] + [tabulate*/boolean (-> (non-empty-listof procedure?) (listof list?))] [table->function (-> (listof (*list/c any/c any/c)) procedure?)] [table->function/list (-> (listof (*list/c any/c any/c)) procedure?)] [enumerate-boolean-tables (-> number? (stream/c (listof (*list/c boolean? boolean?))))] @@ -69,6 +70,18 @@ (check-equal? (tabulate/boolean (lambda (x y) (and x y))) '((#f #f #f) (#f #t #f) (#t #f #f) (#t #t #t))))) +;;; Like tabulate/boolean, but takes a list of functions of the same +;;; arity. +(define (tabulate*/boolean funcs) + (define doms (make-list (procedure-arity (car funcs)) '(#f #t))) + (tabulate* funcs doms)) + +(module+ test + (test-case "tabulate*/boolean" + (check-equal? (tabulate*/boolean `(,(λ (x y) (and x y)) + ,(λ (x y) (or x y)))) + '((#f #f #f #f) (#f #t #f #t) (#t #f #f #t) (#t #t #t #t))))) + ;;; ====================== ;;; Constructing functions