functions: Add sbf?.
This commit is contained in:
parent
c7c50e7152
commit
e5d07b2f13
1 changed files with 11 additions and 1 deletions
|
@ -39,7 +39,10 @@
|
||||||
[read-org-tbfs (->* (string?) (#:headers boolean?) (listof tbf?))]
|
[read-org-tbfs (->* (string?) (#:headers boolean?) (listof tbf?))]
|
||||||
[tbf-tabulate* (-> (listof tbf?) (listof (listof (or/c 0 1))))]
|
[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?)))]))
|
[tbf-tabulate*/boolean (-> (listof tbf?) (listof (listof boolean?)))])
|
||||||
|
;; Predicates
|
||||||
|
(contract-out
|
||||||
|
[sbf? (-> any/c boolean?)]))
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(require rackunit))
|
(require rackunit))
|
||||||
|
@ -366,3 +369,10 @@
|
||||||
(test-case "tbf-tabulate*/boolean"
|
(test-case "tbf-tabulate*/boolean"
|
||||||
(check-equal? (tbf-tabulate*/boolean `(,(tbf #(1 2) 1)))
|
(check-equal? (tbf-tabulate*/boolean `(,(tbf #(1 2) 1)))
|
||||||
'((#f #f #f) (#f #t #t) (#t #f #f) (#t #t #t)))))
|
'((#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))))
|
||||||
|
|
Loading…
Reference in a new issue