diff --git a/functions.rkt b/functions.rkt index 8c6f537..50055ca 100644 --- a/functions.rkt +++ b/functions.rkt @@ -40,7 +40,8 @@ [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?)))] - [sbf (-> (vectorof number?) tbf?)]) + [sbf (-> (vectorof number?) tbf?)] + [list->sbf (-> (listof number?) sbf?)]) ;; Predicates (contract-out [sbf? (-> any/c boolean?)])) @@ -383,3 +384,10 @@ (module+ test (check-equal? (sbf #(1 -1)) (tbf '#(1 -1) 0))) + +;;; Converts a list of numbers to an SBF. The elements of the list +;;; are taken to be the weights of the SBF. +(define list->sbf (compose sbf list->vector)) + +(module+ test + (check-equal? (list->sbf '(1 -1)) (tbf '#(1 -1) 0)))