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

38 lines
1.3 KiB
Scheme
Raw Normal View History

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