Type list->sbf.
This commit is contained in:
parent
945dfe1490
commit
ef979d6dce
2 changed files with 19 additions and 9 deletions
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
(struct-out tbf) tbf-w tbf-θ boolean->01/vector apply-tbf apply-tbf/boolean
|
(struct-out tbf) tbf-w tbf-θ boolean->01/vector apply-tbf apply-tbf/boolean
|
||||||
list->tbf lists->tbfs read-org-tbfs tbf-tabulate* tbf-tabulate
|
list->tbf lists->tbfs read-org-tbfs tbf-tabulate* tbf-tabulate
|
||||||
tbf-tabulate*/boolean sbf? sbf)
|
tbf-tabulate*/boolean sbf? sbf list->sbf)
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(require typed/rackunit))
|
(require typed/rackunit))
|
||||||
|
@ -556,6 +556,13 @@
|
||||||
(test-case "sbf"
|
(test-case "sbf"
|
||||||
(check-equal? (sbf #(1 -1)) (tbf '#(1 -1) 0))))
|
(check-equal? (sbf #(1 -1)) (tbf '#(1 -1) 0))))
|
||||||
|
|
||||||
|
(: list->sbf (-> (Listof Real) tbf))
|
||||||
|
(define (list->sbf lst) (sbf (list->vector lst)))
|
||||||
|
|
||||||
|
(module+ test
|
||||||
|
(test-case "list->sbf"
|
||||||
|
(check-equal? (list->sbf '(1 -1)) (tbf '#(1 -1) 0))))
|
||||||
|
|
||||||
(module untyped racket
|
(module untyped racket
|
||||||
(module+ test
|
(module+ test
|
||||||
(require rackunit))
|
(require rackunit))
|
||||||
|
@ -646,7 +653,7 @@
|
||||||
|
|
||||||
(struct-out tbf) tbf-w tbf-θ boolean->01/vector apply-tbf apply-tbf/boolean
|
(struct-out tbf) tbf-w tbf-θ boolean->01/vector apply-tbf apply-tbf/boolean
|
||||||
list->tbf lists->tbfs read-org-tbfs tbf-tabulate* tbf-tabulate
|
list->tbf lists->tbfs read-org-tbfs tbf-tabulate* tbf-tabulate
|
||||||
tbf-tabulate*/boolean sbf? sbf)
|
tbf-tabulate*/boolean sbf? sbf list->sbf)
|
||||||
|
|
||||||
(require (rename-in (submod 'typed untyped)
|
(require (rename-in (submod 'typed untyped)
|
||||||
[tabulate tabulate/untyped]
|
[tabulate tabulate/untyped]
|
||||||
|
@ -655,7 +662,6 @@
|
||||||
(provide
|
(provide
|
||||||
;; Functions
|
;; Functions
|
||||||
(contract-out
|
(contract-out
|
||||||
[list->sbf (-> (listof number?) sbf?)]
|
|
||||||
[read-org-sbfs (->* (string?) (#:headers boolean?) (listof sbf?))]))
|
[read-org-sbfs (->* (string?) (#:headers boolean?) (listof sbf?))]))
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
|
@ -666,13 +672,7 @@
|
||||||
;;; Threshold Boolean functions
|
;;; Threshold Boolean functions
|
||||||
;;; ===========================
|
;;; ===========================
|
||||||
|
|
||||||
;;; 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
|
|
||||||
(test-case "list->sbf"
|
|
||||||
(check-equal? (list->sbf '(1 -1)) (tbf '#(1 -1) 0))))
|
|
||||||
|
|
||||||
;;; Reads a list of SBF from an Org-mode string containing a sexp,
|
;;; Reads a list of SBF from an Org-mode string containing a sexp,
|
||||||
;;; containing a list of lists of numbers. If headers is #t, drops
|
;;; containing a list of lists of numbers. If headers is #t, drops
|
||||||
|
|
|
@ -582,6 +582,16 @@ Creates a TBF which is an SBF from a vector of weights.
|
||||||
(sbf #(1 -1))
|
(sbf #(1 -1))
|
||||||
]}
|
]}
|
||||||
|
|
||||||
|
@defproc[(list->sbf [lst (Listof Real)])
|
||||||
|
tbf]{
|
||||||
|
|
||||||
|
Converts a list of numbers to an SBF. The elements of the list are taken to be
|
||||||
|
the weights of the SBF.
|
||||||
|
|
||||||
|
@ex[
|
||||||
|
(list->sbf '(1 -1))
|
||||||
|
]}
|
||||||
|
|
||||||
@section[#:tag "fuctions/untyped"]{Untyped definitions}
|
@section[#:tag "fuctions/untyped"]{Untyped definitions}
|
||||||
|
|
||||||
@defmodule[(submod dds/functions typed untyped)]
|
@defmodule[(submod dds/functions typed untyped)]
|
||||||
|
|
Loading…
Reference in a new issue