Type tbf-tabulate.
This commit is contained in:
parent
da6f5acf4e
commit
9db0fcbdb4
2 changed files with 20 additions and 12 deletions
|
@ -30,7 +30,7 @@
|
||||||
random-boolean-table random-boolean-function random-boolean-function/list
|
random-boolean-table random-boolean-function random-boolean-function/list
|
||||||
|
|
||||||
(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*)
|
list->tbf lists->tbfs read-org-tbfs tbf-tabulate* tbf-tabulate)
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(require typed/rackunit))
|
(require typed/rackunit))
|
||||||
|
@ -515,6 +515,15 @@
|
||||||
(check-equal? (tbf-tabulate* (list (tbf #(2 2) 1) (tbf #(1 1) 1)))
|
(check-equal? (tbf-tabulate* (list (tbf #(2 2) 1) (tbf #(1 1) 1)))
|
||||||
'((0 0 0 0) (0 1 1 0) (1 0 1 0) (1 1 1 1)))))
|
'((0 0 0 0) (0 1 1 0) (1 0 1 0) (1 1 1 1)))))
|
||||||
|
|
||||||
|
(: tbf-tabulate (-> tbf (Listof (Listof (U Zero One)))))
|
||||||
|
(define (tbf-tabulate t)
|
||||||
|
(tbf-tabulate* (list t)))
|
||||||
|
|
||||||
|
(module+ test
|
||||||
|
(test-case "tbf-tabulate"
|
||||||
|
(check-equal? (tbf-tabulate (tbf #(1 2) 1))
|
||||||
|
'((0 0 0) (0 1 1) (1 0 0) (1 1 1)))))
|
||||||
|
|
||||||
(module untyped racket
|
(module untyped racket
|
||||||
(module+ test
|
(module+ test
|
||||||
(require rackunit))
|
(require rackunit))
|
||||||
|
@ -604,7 +613,7 @@
|
||||||
random-boolean-table random-boolean-function random-boolean-function/list
|
random-boolean-table random-boolean-function random-boolean-function/list
|
||||||
|
|
||||||
(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*)
|
list->tbf lists->tbfs read-org-tbfs tbf-tabulate* tbf-tabulate)
|
||||||
|
|
||||||
(require (rename-in (submod 'typed untyped)
|
(require (rename-in (submod 'typed untyped)
|
||||||
[tabulate tabulate/untyped]
|
[tabulate tabulate/untyped]
|
||||||
|
@ -613,7 +622,6 @@
|
||||||
(provide
|
(provide
|
||||||
;; Functions
|
;; Functions
|
||||||
(contract-out
|
(contract-out
|
||||||
[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?)))]
|
||||||
[sbf (-> (vectorof number?) tbf?)]
|
[sbf (-> (vectorof number?) tbf?)]
|
||||||
[list->sbf (-> (listof number?) sbf?)]
|
[list->sbf (-> (listof number?) sbf?)]
|
||||||
|
@ -630,15 +638,6 @@
|
||||||
;;; Threshold Boolean functions
|
;;; Threshold Boolean functions
|
||||||
;;; ===========================
|
;;; ===========================
|
||||||
|
|
||||||
|
|
||||||
;;; Tabulates a TBF.
|
|
||||||
(define tbf-tabulate (compose tbf-tabulate* list))
|
|
||||||
|
|
||||||
(module+ test
|
|
||||||
(test-case "tbf-tabulate"
|
|
||||||
(check-equal? (tbf-tabulate (tbf #(1 2) 1))
|
|
||||||
'((0 0 0) (0 1 1) (1 0 0) (1 1 1)))))
|
|
||||||
|
|
||||||
;;; Tabulates a list of TBFs like tbf-boolean*, but uses Boolean
|
;;; Tabulates a list of TBFs like tbf-boolean*, but uses Boolean
|
||||||
;;; values #f and #t instead of 0 and 1.
|
;;; values #f and #t instead of 0 and 1.
|
||||||
;;;
|
;;;
|
||||||
|
|
|
@ -543,6 +543,15 @@ TBF in the list.
|
||||||
(tbf-tabulate* (list (tbf #(2 2) 1) (tbf #(1 1) 1)))
|
(tbf-tabulate* (list (tbf #(2 2) 1) (tbf #(1 1) 1)))
|
||||||
]}
|
]}
|
||||||
|
|
||||||
|
@defproc[(tbf-tabulate [t tbf])
|
||||||
|
(Listof (Listof (U Zero One)))]{
|
||||||
|
|
||||||
|
Tabulates a single TBF.
|
||||||
|
|
||||||
|
@ex[
|
||||||
|
(tbf-tabulate (tbf #(1 2) 1))
|
||||||
|
]}
|
||||||
|
|
||||||
@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