functions: Add vector-boolean->01.

This commit is contained in:
Sergiu Ivanov 2020-06-10 23:51:01 +02:00
parent 45f4984f4c
commit dc3a0072a2

View File

@ -30,7 +30,8 @@
[random-boolean-function (-> number? procedure?)]
[random-boolean-function/list (-> number? procedure?)]
[tbf-w (-> tbf? (vectorof number?))]
[tbf-θ (-> tbf? number?)]))
[tbf-θ (-> tbf? number?)]
[vector-boolean->01 (-> (vectorof boolean?) (vectorof (or/c 0 1)))]))
(module+ test
(require rackunit))
@ -236,3 +237,11 @@
;;; Unicode shortcuts for accessing the elements of a TBF.
(define tbf-w tbf-weights)
(define tbf-θ tbf-threshold)
;;; Converts a Boolean vector to a 0-1 vector.
(define (vector-boolean->01 bool-v)
(vector-map any->01 bool-v))
(module+ test
(test-case "boolean->0-1"
(check-equal? (vector-boolean->01 #(#t #f #f)) #(1 0 0))))