From ac0f90ce235aa03e5abc83386450f2b546105478 Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Sun, 12 Jul 2020 23:58:55 +0200 Subject: [PATCH] functions: Add sbf. --- functions.rkt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/functions.rkt b/functions.rkt index d627cc8..8c6f537 100644 --- a/functions.rkt +++ b/functions.rkt @@ -39,7 +39,8 @@ [read-org-tbfs (->* (string?) (#:headers boolean?) (listof tbf?))] [tbf-tabulate* (-> (listof tbf?) (listof (listof (or/c 0 1))))] [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?)]) ;; Predicates (contract-out [sbf? (-> any/c boolean?)])) @@ -376,3 +377,9 @@ (module+ test (check-false (sbf? (tbf #(1 2) 3))) (check-true (sbf? (tbf #(1 2) 0)))) + +;;; Creates a TBF which is an SBF from a vector of weights. +(define (sbf w) (tbf w 0)) + +(module+ test + (check-equal? (sbf #(1 -1)) (tbf '#(1 -1) 0)))