diff --git a/functions.rkt b/functions.rkt index 929d083..d627cc8 100644 --- a/functions.rkt +++ b/functions.rkt @@ -39,7 +39,10 @@ [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*/boolean (-> (listof tbf?) (listof (listof boolean?)))])) + [tbf-tabulate*/boolean (-> (listof tbf?) (listof (listof boolean?)))]) + ;; Predicates + (contract-out + [sbf? (-> any/c boolean?)])) (module+ test (require rackunit)) @@ -366,3 +369,10 @@ (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))))) + +;;; A sign Boolean function (SBF) is a TBF whose threshold is 0. +(define sbf? (and/c tbf? (λ (x) (= 0 (tbf-θ x))))) + +(module+ test + (check-false (sbf? (tbf #(1 2) 3))) + (check-true (sbf? (tbf #(1 2) 0))))