Type sbf?.
This commit is contained in:
parent
297d455207
commit
6d37f180ba
2 changed files with 21 additions and 14 deletions
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
(struct-out tbf) tbf-w tbf-θ boolean->01/vector apply-tbf apply-tbf/boolean
|
(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
|
list->tbf lists->tbfs read-org-tbfs tbf-tabulate* tbf-tabulate
|
||||||
tbf-tabulate*/boolean)
|
tbf-tabulate*/boolean sbf?)
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(require typed/rackunit))
|
(require typed/rackunit))
|
||||||
|
@ -539,6 +539,15 @@
|
||||||
(check-equal? (tbf-tabulate*/boolean (list (tbf #(1 2) 1)))
|
(check-equal? (tbf-tabulate*/boolean (list (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)))))
|
||||||
|
|
||||||
|
(: 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 untyped racket
|
||||||
(module+ test
|
(module+ test
|
||||||
(require rackunit))
|
(require rackunit))
|
||||||
|
@ -629,7 +638,7 @@
|
||||||
|
|
||||||
(struct-out tbf) tbf-w tbf-θ boolean->01/vector apply-tbf apply-tbf/boolean
|
(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
|
list->tbf lists->tbfs read-org-tbfs tbf-tabulate* tbf-tabulate
|
||||||
tbf-tabulate*/boolean)
|
tbf-tabulate*/boolean sbf?)
|
||||||
|
|
||||||
(require (rename-in (submod 'typed untyped)
|
(require (rename-in (submod 'typed untyped)
|
||||||
[tabulate tabulate/untyped]
|
[tabulate tabulate/untyped]
|
||||||
|
@ -640,10 +649,7 @@
|
||||||
(contract-out
|
(contract-out
|
||||||
[sbf (-> (vectorof number?) tbf?)]
|
[sbf (-> (vectorof number?) tbf?)]
|
||||||
[list->sbf (-> (listof number?) sbf?)]
|
[list->sbf (-> (listof number?) sbf?)]
|
||||||
[read-org-sbfs (->* (string?) (#:headers boolean?) (listof sbf?))])
|
[read-org-sbfs (->* (string?) (#:headers boolean?) (listof sbf?))]))
|
||||||
;; Predicates
|
|
||||||
(contract-out
|
|
||||||
[sbf? (-> any/c boolean?)]))
|
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(require rackunit))
|
(require rackunit))
|
||||||
|
@ -653,14 +659,6 @@
|
||||||
;;; Threshold Boolean functions
|
;;; 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.
|
;;; Creates a TBF which is an SBF from a vector of weights.
|
||||||
(define (sbf w) (tbf w 0))
|
(define (sbf w) (tbf w 0))
|
||||||
|
|
||||||
|
|
|
@ -565,6 +565,15 @@ TBF in the list.
|
||||||
(tbf-tabulate*/boolean (list (tbf #(1 2) 1)))
|
(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}
|
@section[#:tag "fuctions/untyped"]{Untyped definitions}
|
||||||
|
|
||||||
@defmodule[(submod dds/functions typed untyped)]
|
@defmodule[(submod dds/functions typed untyped)]
|
||||||
|
|
Loading…
Reference in a new issue