Type sbf.
This commit is contained in:
parent
6d37f180ba
commit
945dfe1490
2 changed files with 18 additions and 10 deletions
|
@ -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 sbf?)
|
||||
tbf-tabulate*/boolean sbf? sbf)
|
||||
|
||||
(module+ test
|
||||
(require typed/rackunit))
|
||||
|
@ -548,6 +548,14 @@
|
|||
(check-false (sbf? (tbf #(1 2) 3)))
|
||||
(check-true (sbf? (tbf #(1 2) 0)))))
|
||||
|
||||
(: sbf (-> (Vectorof Real) tbf))
|
||||
(define (sbf w)
|
||||
(tbf w 0))
|
||||
|
||||
(module+ test
|
||||
(test-case "sbf"
|
||||
(check-equal? (sbf #(1 -1)) (tbf '#(1 -1) 0))))
|
||||
|
||||
(module untyped racket
|
||||
(module+ test
|
||||
(require rackunit))
|
||||
|
@ -638,7 +646,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 sbf?)
|
||||
tbf-tabulate*/boolean sbf? sbf)
|
||||
|
||||
(require (rename-in (submod 'typed untyped)
|
||||
[tabulate tabulate/untyped]
|
||||
|
@ -647,7 +655,6 @@
|
|||
(provide
|
||||
;; Functions
|
||||
(contract-out
|
||||
[sbf (-> (vectorof number?) tbf?)]
|
||||
[list->sbf (-> (listof number?) sbf?)]
|
||||
[read-org-sbfs (->* (string?) (#:headers boolean?) (listof sbf?))]))
|
||||
|
||||
|
@ -659,13 +666,6 @@
|
|||
;;; Threshold Boolean functions
|
||||
;;; ===========================
|
||||
|
||||
;;; Creates a TBF which is an SBF from a vector of weights.
|
||||
(define (sbf w) (tbf w 0))
|
||||
|
||||
(module+ test
|
||||
(test-case "sbf"
|
||||
(check-equal? (sbf #(1 -1)) (tbf '#(1 -1) 0))))
|
||||
|
||||
;;; Converts a list of numbers to an SBF. The elements of the list
|
||||
;;; are taken to be the weights of the SBF.
|
||||
(define list->sbf (compose sbf list->vector))
|
||||
|
|
|
@ -574,6 +574,14 @@ A sign Boolean function (SBF) is a TBF whose threshold is 0.
|
|||
(sbf? (tbf #(1 2) 0))
|
||||
]}
|
||||
|
||||
@defproc[(sbf [w (Vectorof Real)]) tbf]{
|
||||
|
||||
Creates a TBF which is an SBF from a vector of weights.
|
||||
|
||||
@ex[
|
||||
(sbf #(1 -1))
|
||||
]}
|
||||
|
||||
@section[#:tag "fuctions/untyped"]{Untyped definitions}
|
||||
|
||||
@defmodule[(submod dds/functions typed untyped)]
|
||||
|
|
Loading…
Reference in a new issue