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

36 lines
1.2 KiB
Scheme
Raw Normal View History

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