check-errors/type-checks-numbers.bignum.scm

36 lines
1.2 KiB
Scheme
Raw Normal View History

2024-09-25 15:33:04 +00:00
;;;; type-checks-numbers.bignum.scm -*- Scheme -*-
;;;; Kon Lovett, Jun '18
(module (type-checks-numbers bignum)
(;export
check-bignum
check-positive-bignum check-non-negative-bignum check-negative-bignum
check-non-positive-bignum)
(import scheme)
(import (chicken base))
(import (chicken module))
(import (chicken type))
(import type-checks-basic)
(import (type-errors-numbers bignum))
(: check-bignum (* bignum #!optional * -> bignum))
(: check-positive-bignum (* bignum #!optional * -> bignum))
(: check-non-negative-bignum (* bignum #!optional * -> bignum ))
(: check-negative-bignum (* bignum #!optional * -> bignum))
(: check-non-positive-bignum (* bignum #!optional * -> bignum))
(define (positive-bignum? x) (and (bignum? x) (positive? x)))
(define (non-negative-bignum? x) (and (bignum? x) (or (zero? x) (positive? x))))
(define (negative-bignum? x) (and (bignum? x) (negative? x)))
(define (non-positive-bignum? x) (and (bignum? x) (or (zero? x) (negative? x))))
(define-check-type bignum)
(define-check-type positive-bignum)
(define-check-type non-negative-bignum)
(define-check-type negative-bignum)
(define-check-type non-positive-bignum)
) ;module (type-checks-numbers bignum)