functions: Add tabulate*/boolean.

This commit is contained in:
Sergiu Ivanov 2020-05-31 23:31:54 +02:00
parent 26c615e6cf
commit 78386dd5bf
1 changed files with 13 additions and 0 deletions

View File

@ -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