Type tbf.

This commit is contained in:
Sergiu Ivanov 2022-04-21 11:42:50 +02:00
parent 212440add1
commit cc137a5459
2 changed files with 15 additions and 9 deletions

View file

@ -25,7 +25,9 @@
table->function/list table->function table->function/pv table->function/list table->function table->function/pv
enumerate-boolean-tables enumerate-boolean-functions enumerate-boolean-tables enumerate-boolean-functions
enumerate-boolean-functions/pv enumerate-boolean-functions/list enumerate-boolean-functions/pv enumerate-boolean-functions/list
random-boolean-table random-boolean-function random-boolean-function/list) random-boolean-table random-boolean-function random-boolean-function/list
(struct-out tbf))
(module+ test (module+ test
(require typed/rackunit)) (require typed/rackunit))
@ -354,6 +356,8 @@
(check-false (random-bool-f/list '(#t #f))) (check-false (random-bool-f/list '(#t #f)))
(check-true (random-bool-f/list '(#t #t))))) (check-true (random-bool-f/list '(#t #t)))))
(struct tbf ([weights : (Vectorof Real)] [threshold : Real]) #:transparent)
(module untyped racket (module untyped racket
(module+ test (module+ test
(require rackunit)) (require rackunit))
@ -438,16 +442,15 @@
table->function/list table->function table->function/pv table->function/list table->function table->function/pv
enumerate-boolean-tables enumerate-boolean-functions enumerate-boolean-tables enumerate-boolean-functions
enumerate-boolean-functions/pv enumerate-boolean-functions/list enumerate-boolean-functions/pv enumerate-boolean-functions/list
random-boolean-table random-boolean-function random-boolean-function/list) random-boolean-table random-boolean-function random-boolean-function/list
(struct-out tbf))
(require (rename-in (submod 'typed untyped) (require (rename-in (submod 'typed untyped)
[tabulate tabulate/untyped] [tabulate tabulate/untyped]
[tabulate* tabulate*/untyped])) [tabulate* tabulate*/untyped]))
(provide (provide
;; Structures
(contract-out
[struct tbf ((weights (vectorof number?)) (threshold number?))])
;; Functions ;; Functions
(contract-out (contract-out
[tbf-w (-> tbf? (vectorof number?))] [tbf-w (-> tbf? (vectorof number?))]
@ -476,10 +479,6 @@
;;; Threshold Boolean functions ;;; Threshold Boolean functions
;;; =========================== ;;; ===========================
;;; A threshold Boolean function (TBF) is a pair (w, θ), where w is a
;;; vector of weights and θ is the threshold.
(struct tbf (weights threshold) #:transparent)
;;; Unicode shortcuts for accessing the elements of a TBF. ;;; Unicode shortcuts for accessing the elements of a TBF.
(define tbf-w tbf-weights) (define tbf-w tbf-weights)
(define tbf-θ tbf-threshold) (define tbf-θ tbf-threshold)

View file

@ -369,6 +369,13 @@ a list of arguments.
@section{Threshold Boolean functions} @section{Threshold Boolean functions}
@defstruct*[tbf ([weights (Vectorof Real)] [threshold Real])]{
A threshold Boolean function (TBF) is a pair @tt{(w, θ)}, where @tt{w} is
a vector of weights and @tt{θ} is the threshold.
}
@section[#:tag "fuctions/untyped"]{Untyped definitions} @section[#:tag "fuctions/untyped"]{Untyped definitions}
@defmodule[(submod dds/functions typed untyped)] @defmodule[(submod dds/functions typed untyped)]