vector-boolean->01 → boolean->01/vector
This commit is contained in:
parent
dc8a098234
commit
027022524b
2 changed files with 8 additions and 8 deletions
|
@ -27,7 +27,7 @@
|
||||||
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) tbf-w tbf-θ vector-boolean->01)
|
(struct-out tbf) tbf-w tbf-θ boolean->01/vector)
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(require typed/rackunit))
|
(require typed/rackunit))
|
||||||
|
@ -360,13 +360,13 @@
|
||||||
(define tbf-w tbf-weights)
|
(define tbf-w tbf-weights)
|
||||||
(define tbf-θ tbf-threshold)
|
(define tbf-θ tbf-threshold)
|
||||||
|
|
||||||
(: vector-boolean->01 (-> (Vectorof Boolean) (Vectorof (U Zero One))))
|
(: boolean->01/vector (-> (Vectorof Boolean) (Vectorof (U Zero One))))
|
||||||
(define (vector-boolean->01 bool-v)
|
(define (boolean->01/vector bool-v)
|
||||||
(vector-map (λ (x) (any->01 x)) bool-v))
|
(vector-map (λ (x) (any->01 x)) bool-v))
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(test-case "vector-boolean->01"
|
(test-case "boolean->01/vector"
|
||||||
(check-equal? (vector-boolean->01 #(#t #f #f)) #(1 0 0))))
|
(check-equal? (boolean->01/vector #(#t #f #f)) #(1 0 0))))
|
||||||
|
|
||||||
(module untyped racket
|
(module untyped racket
|
||||||
(module+ test
|
(module+ test
|
||||||
|
@ -454,7 +454,7 @@
|
||||||
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) tbf-w tbf-θ vector-boolean->01)
|
(struct-out tbf) tbf-w tbf-θ boolean->01/vector)
|
||||||
|
|
||||||
(require (rename-in (submod 'typed untyped)
|
(require (rename-in (submod 'typed untyped)
|
||||||
[tabulate tabulate/untyped]
|
[tabulate tabulate/untyped]
|
||||||
|
|
|
@ -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))]{
|
(Vectorof (U Zero One))]{
|
||||||
|
|
||||||
Converts a Boolean vector to a vector of zeros and ones.
|
Converts a Boolean vector to a vector of zeros and ones.
|
||||||
|
|
||||||
@examples[#:eval functions-evaluator
|
@examples[#:eval functions-evaluator
|
||||||
(vector-boolean->01 #(#t #f #f))
|
(boolean->01/vector #(#t #f #f))
|
||||||
]}
|
]}
|
||||||
|
|
||||||
@section[#:tag "fuctions/untyped"]{Untyped definitions}
|
@section[#:tag "fuctions/untyped"]{Untyped definitions}
|
||||||
|
|
Loading…
Reference in a new issue