From cc137a5459256f030e7b500b17be4ac6e466ff99 Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Thu, 21 Apr 2022 11:42:50 +0200 Subject: [PATCH] Type tbf. --- functions.rkt | 17 ++++++++--------- scribblings/functions.scrbl | 7 +++++++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/functions.rkt b/functions.rkt index 64313b3..fdf827c 100644 --- a/functions.rkt +++ b/functions.rkt @@ -25,7 +25,9 @@ table->function/list table->function table->function/pv enumerate-boolean-tables enumerate-boolean-functions 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 (require typed/rackunit)) @@ -354,6 +356,8 @@ (check-false (random-bool-f/list '(#t #f))) (check-true (random-bool-f/list '(#t #t))))) + (struct tbf ([weights : (Vectorof Real)] [threshold : Real]) #:transparent) + (module untyped racket (module+ test (require rackunit)) @@ -438,16 +442,15 @@ table->function/list table->function table->function/pv enumerate-boolean-tables enumerate-boolean-functions 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) [tabulate tabulate/untyped] [tabulate* tabulate*/untyped])) (provide - ;; Structures - (contract-out - [struct tbf ((weights (vectorof number?)) (threshold number?))]) ;; Functions (contract-out [tbf-w (-> tbf? (vectorof number?))] @@ -476,10 +479,6 @@ ;;; 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. (define tbf-w tbf-weights) (define tbf-θ tbf-threshold) diff --git a/scribblings/functions.scrbl b/scribblings/functions.scrbl index c593e1c..655e6b7 100644 --- a/scribblings/functions.scrbl +++ b/scribblings/functions.scrbl @@ -369,6 +369,13 @@ a list of arguments. @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} @defmodule[(submod dds/functions typed untyped)]