diff --git a/functions.rkt b/functions.rkt index 3a1b5d2..44d9872 100644 --- a/functions.rkt +++ b/functions.rkt @@ -31,7 +31,7 @@ (struct-out tbf) tbf-w tbf-θ boolean->01/vector apply-tbf apply-tbf/boolean list->tbf lists->tbfs read-org-tbfs tbf-tabulate* tbf-tabulate - tbf-tabulate*/boolean) + tbf-tabulate*/boolean sbf?) (module+ test (require typed/rackunit)) @@ -539,6 +539,15 @@ (check-equal? (tbf-tabulate*/boolean (list (tbf #(1 2) 1))) '((#f #f #f) (#f #t #t) (#t #f #f) (#t #t #t))))) + (: sbf? (-> tbf Boolean)) + (define (sbf? t) + (= 0 (tbf-θ t))) + + (module+ test + (test-case "sbf?" + (check-false (sbf? (tbf #(1 2) 3))) + (check-true (sbf? (tbf #(1 2) 0))))) + (module untyped racket (module+ test (require rackunit)) @@ -629,7 +638,7 @@ (struct-out tbf) tbf-w tbf-θ boolean->01/vector apply-tbf apply-tbf/boolean list->tbf lists->tbfs read-org-tbfs tbf-tabulate* tbf-tabulate - tbf-tabulate*/boolean) + tbf-tabulate*/boolean sbf?) (require (rename-in (submod 'typed untyped) [tabulate tabulate/untyped] @@ -640,10 +649,7 @@ (contract-out [sbf (-> (vectorof number?) tbf?)] [list->sbf (-> (listof number?) sbf?)] - [read-org-sbfs (->* (string?) (#:headers boolean?) (listof sbf?))]) - ;; Predicates - (contract-out - [sbf? (-> any/c boolean?)])) + [read-org-sbfs (->* (string?) (#:headers boolean?) (listof sbf?))])) (module+ test (require rackunit)) @@ -653,14 +659,6 @@ ;;; Threshold Boolean functions ;;; =========================== -;;; A sign Boolean function (SBF) is a TBF whose threshold is 0. -(define sbf? (and/c tbf? (λ (x) (= 0 (tbf-θ x))))) - -(module+ test - (test-case "sbf?" - (check-false (sbf? (tbf #(1 2) 3))) - (check-true (sbf? (tbf #(1 2) 0))))) - ;;; Creates a TBF which is an SBF from a vector of weights. (define (sbf w) (tbf w 0)) diff --git a/scribblings/functions.scrbl b/scribblings/functions.scrbl index a12d149..2e34d18 100644 --- a/scribblings/functions.scrbl +++ b/scribblings/functions.scrbl @@ -565,6 +565,15 @@ TBF in the list. (tbf-tabulate*/boolean (list (tbf #(1 2) 1))) ]} +@defproc[(sbf? [t tbf]) Boolean]{ + +A sign Boolean function (SBF) is a TBF whose threshold is 0. + +@ex[ +(sbf? (tbf #(1 2) 3)) +(sbf? (tbf #(1 2) 0)) +]} + @section[#:tag "fuctions/untyped"]{Untyped definitions} @defmodule[(submod dds/functions typed untyped)]