functions: Add sbf.

This commit is contained in:
Sergiu Ivanov 2020-07-12 23:58:55 +02:00
parent e5d07b2f13
commit ac0f90ce23

View file

@ -39,7 +39,8 @@
[read-org-tbfs (->* (string?) (#:headers boolean?) (listof tbf?))] [read-org-tbfs (->* (string?) (#:headers boolean?) (listof tbf?))]
[tbf-tabulate* (-> (listof tbf?) (listof (listof (or/c 0 1))))] [tbf-tabulate* (-> (listof tbf?) (listof (listof (or/c 0 1))))]
[tbf-tabulate (-> 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 ;; Predicates
(contract-out (contract-out
[sbf? (-> any/c boolean?)])) [sbf? (-> any/c boolean?)]))
@ -376,3 +377,9 @@
(module+ test (module+ test
(check-false (sbf? (tbf #(1 2) 3))) (check-false (sbf? (tbf #(1 2) 3)))
(check-true (sbf? (tbf #(1 2) 0)))) (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)))