diff --git a/functions.rkt b/functions.rkt index 6f97e03..929d083 100644 --- a/functions.rkt +++ b/functions.rkt @@ -38,7 +38,8 @@ [read-tbfs (-> (listof (listof number?)) (listof tbf?))] [read-org-tbfs (->* (string?) (#:headers boolean?) (listof tbf?))] [tbf-tabulate* (-> (listof tbf?) (listof (listof (or/c 0 1))))] - [tbf-tabulate (-> tbf? (listof (listof (or/c 0 1))))])) + [tbf-tabulate (-> tbf? (listof (listof (or/c 0 1))))] + [tbf-tabulate*/boolean (-> (listof tbf?) (listof (listof boolean?)))])) (module+ test (require rackunit)) @@ -348,3 +349,20 @@ (test-case "tbf-tabulate" (check-equal? (tbf-tabulate (tbf #(1 2) 1)) '((0 0 0) (0 1 1) (1 0 0) (1 1 1))))) + +;;; Tabulates a list of TBFs like tbf-boolean*, but uses Boolean +;;; values #f and #t instead of 0 and 1. +;;; +;;; All the TBFs in tbfs must have the same number of inputs as the +;;; first TBF in the list. This function does not check this +;;; condition. +(define (tbf-tabulate*/boolean tbfs) + (define funcs (for/list ([tbf tbfs]) + (λ in (apply-tbf/boolean tbf (list->vector in))))) + (define nvars (vector-length (tbf-w (car tbfs)))) + (tabulate* funcs (make-list nvars '(#f #t)))) + +(module+ test + (test-case "tbf-tabulate*/boolean" + (check-equal? (tbf-tabulate*/boolean `(,(tbf #(1 2) 1))) + '((#f #f #f) (#f #t #t) (#t #f #f) (#t #t #t)))))