39 lines
1.3 KiB
Scheme
39 lines
1.3 KiB
Scheme
|
;;;; type-checks-numbers.fixnum.scm -*- Scheme -*-
|
||
|
;;;; Kon Lovett, Jun '18
|
||
|
|
||
|
(module (type-checks-numbers fixnum)
|
||
|
|
||
|
(;export
|
||
|
check-fixnum
|
||
|
check-positive-fixnum check-non-negative-fixnum check-natural-fixnum
|
||
|
check-negative-fixnum check-non-positive-fixnum)
|
||
|
|
||
|
(import scheme)
|
||
|
(import (chicken base))
|
||
|
(import (chicken module))
|
||
|
(import (chicken type))
|
||
|
(import (chicken fixnum))
|
||
|
(import type-checks-basic)
|
||
|
(import (type-errors-numbers fixnum))
|
||
|
|
||
|
(: check-fixnum (* fixnum #!optional * -> fixnum))
|
||
|
(: check-positive-fixnum (* fixnum #!optional * -> fixnum))
|
||
|
(: check-non-negative-fixnum (* fixnum #!optional * -> fixnum))
|
||
|
(: check-natural-fixnum (* fixnum #!optional * -> fixnum))
|
||
|
(: check-negative-fixnum (* fixnum #!optional * -> fixnum))
|
||
|
(: check-non-positive-fixnum (* fixnum #!optional * -> fixnum))
|
||
|
|
||
|
(define (positive-fixnum? x) (and (fixnum? x) (fx< 0 x)))
|
||
|
(define (non-negative-fixnum? x) (and (fixnum? x) (fx<= 0 x)))
|
||
|
(define (negative-fixnum? x) (and (fixnum? x) (fx> 0 x)))
|
||
|
(define (non-positive-fixnum? x) (and (fixnum? x) (fx>= 0 x)))
|
||
|
|
||
|
(define-check-type fixnum)
|
||
|
(define-check-type positive-fixnum)
|
||
|
(define-check-type non-negative-fixnum)
|
||
|
(define check-natural-fixnum check-non-negative-fixnum)
|
||
|
(define-check-type negative-fixnum)
|
||
|
(define-check-type non-positive-fixnum)
|
||
|
|
||
|
) ;module (type-checks-numbers fixnum)
|