vector-boolean->01 → boolean->01/vector

This commit is contained in:
Sergiu Ivanov 2022-04-21 14:06:23 +02:00
parent dc8a098234
commit 027022524b
2 changed files with 8 additions and 8 deletions

View File

@ -27,7 +27,7 @@
enumerate-boolean-functions/pv enumerate-boolean-functions/list
random-boolean-table random-boolean-function random-boolean-function/list
(struct-out tbf) tbf-w tbf-θ vector-boolean->01)
(struct-out tbf) tbf-w tbf-θ boolean->01/vector)
(module+ test
(require typed/rackunit))
@ -360,13 +360,13 @@
(define tbf-w tbf-weights)
(define tbf-θ tbf-threshold)
(: vector-boolean->01 (-> (Vectorof Boolean) (Vectorof (U Zero One))))
(define (vector-boolean->01 bool-v)
(: boolean->01/vector (-> (Vectorof Boolean) (Vectorof (U Zero One))))
(define (boolean->01/vector bool-v)
(vector-map (λ (x) (any->01 x)) bool-v))
(module+ test
(test-case "vector-boolean->01"
(check-equal? (vector-boolean->01 #(#t #f #f)) #(1 0 0))))
(test-case "boolean->01/vector"
(check-equal? (boolean->01/vector #(#t #f #f)) #(1 0 0))))
(module untyped racket
(module+ test
@ -454,7 +454,7 @@
enumerate-boolean-functions/pv enumerate-boolean-functions/list
random-boolean-table random-boolean-function random-boolean-function/list
(struct-out tbf) tbf-w tbf-θ vector-boolean->01)
(struct-out tbf) tbf-w tbf-θ boolean->01/vector)
(require (rename-in (submod 'typed untyped)
[tabulate tabulate/untyped]

View File

@ -383,13 +383,13 @@ Shortcuts for @racket[tbf-weights] and @racket[tbf-threshold].
}
@defproc[(vector-boolean->01 [bool-v (Vectorof Boolean)])
@defproc[(boolean->01/vector [bool-v (Vectorof Boolean)])
(Vectorof (U Zero One))]{
Converts a Boolean vector to a vector of zeros and ones.
@examples[#:eval functions-evaluator
(vector-boolean->01 #(#t #f #f))
(boolean->01/vector #(#t #f #f))
]}
@section[#:tag "fuctions/untyped"]{Untyped definitions}