diff --git a/functions.rkt b/functions.rkt index 76d0b01..5c3fc08 100644 --- a/functions.rkt +++ b/functions.rkt @@ -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))))