From e5d07b2f134c828874af2b37fb8322041a57d98e Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Sun, 12 Jul 2020 23:50:51 +0200 Subject: [PATCH] functions: Add sbf?. --- functions.rkt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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))))