diff --git a/functions.rkt b/functions.rkt index 8fad63b..8739b75 100644 --- a/functions.rkt +++ b/functions.rkt @@ -216,7 +216,7 @@ (module+ test (test-case "tabulate/pv/01" (check-equal? (tabulate/pv/01 2 (pvλ (x y) - (cast (modulo (+ x y) 2) (U Zero One)))) + (assert-type (modulo (+ x y) 2) (U Zero One)))) '((0 0 0) (0 1 1) (1 0 1) (1 1 0))))) (: tabulate*/pv/01 (-> Positive-Integer (Listof (-> (U Zero One) * (U Zero One))) @@ -226,8 +226,8 @@ (module+ test (test-case "tabulate*/pv/01" - (check-equal? (tabulate*/pv/01 2 `(,(pvλ (x y) (cast (min x y) (U Zero One))) - ,(pvλ (x y) (cast (max x y) (U Zero One))))) + (check-equal? (tabulate*/pv/01 2 `(,(pvλ (x y) (assert-type (min x y) (U Zero One))) + ,(pvλ (x y) (assert-type (max x y) (U Zero One))))) '((0 0 0 0) (0 1 0 1) (1 0 0 1) (1 1 1 1))))) (: tabulate/list/boolean (-> Positive-Integer (-> (Listof Boolean) Boolean) @@ -261,7 +261,7 @@ (test-case "tabulate/list/01" (check-equal? (tabulate/list/01 2 (λ (xs) - (cast (modulo (+ (car xs) (cadr xs)) 2) (U Zero One)))) + (assert-type (modulo (+ (car xs) (cadr xs)) 2) (U Zero One)))) '((0 0 0) (0 1 1) (1 0 1) (1 1 0))))) (: tabulate*/list/01 (-> Positive-Integer (Listof (-> (Listof (U Zero One)) (U Zero One))) @@ -273,8 +273,8 @@ (test-case "tabulate*/list/01" (check-equal? (tabulate*/list/01 2 - `(,(λ (xs) (cast (min (car xs) (cadr xs)) (U Zero One))) - ,(λ (xs) (cast (max (car xs) (cadr xs)) (U Zero One))))) + `(,(λ (xs) (assert-type (min (car xs) (cadr xs)) (U Zero One))) + ,(λ (xs) (assert-type (max (car xs) (cadr xs)) (U Zero One))))) '((0 0 0 0) (0 1 0 1) (1 0 0 1) (1 1 1 1))))) (: table->function/list (All (a) (-> (Listof (Listof a)) @@ -324,7 +324,7 @@ (: enumerate-boolean-tables (-> Positive-Integer (Sequenceof (Listof (Listof Boolean))))) (define (enumerate-boolean-tables n) (define inputs (boolean-power n)) - (define outputs (boolean-power/stream (cast (expt 2 n) Integer))) + (define outputs (boolean-power/stream (assert-type (expt 2 n) Integer))) (: append-outputs (-> (Listof (Listof Boolean)) (Listof Boolean) (Listof (Listof Boolean)))) @@ -395,7 +395,7 @@ (: random-boolean-table (-> Positive-Integer (Listof (Listof Boolean)))) (define (random-boolean-table n) (define ins (boolean-power n)) - (define outs (stream-take (in-random 2) (cast (expt 2 n) Nonnegative-Integer))) + (define outs (stream-take (in-random 2) (assert-type (expt 2 n) Nonnegative-Integer))) (for/list ([i ins] [o outs]) (append i (list (if (= o 1) #t #f))))) @@ -492,9 +492,9 @@ (: read-org-tbfs (->* (String) (#:headers Boolean) (Listof tbf))) (define (read-org-tbfs str #:headers [headers #f]) - (define sexp (cast (read-org-sexp str) (Listof Any))) + (define sexp (assert-type (read-org-sexp str) (Listof Any))) (define sexp-clean (cond [headers (cdr sexp)] [else sexp])) - (lists->tbfs (cast sexp-clean (Listof (Listof Real))))) + (lists->tbfs (assert-type sexp-clean (Listof (Listof Real))))) (module+ test (test-case "read-org-tbfs"