3 ;;; Copyright (c) 2005--2007, by A.J. Rossini <blindglobe@gmail.com>
4 ;;; See COPYRIGHT file for any additional restrictions (BSD license).
5 ;;; Since 1991, ANSI was finally finished. Edited for ANSI Common Lisp.
9 (defpackage :lisp-stat-types
11 (:export fixnump check-nonneg-fixnum check-one-fixnum
12 check-one-real check-one-number
))
14 (in-package :lisp-stat-types
)
16 ;;; Type Checking Functions
17 ;;; (Moved out of lsbasics.lsp, placed there by initial design).
21 Returns T if X is a fixnum; NIL otherwise."
22 (declare (inline typep
))
25 (defun check-nonneg-fixnum (x)
26 "Ensure that x or all elts of x are non-negative fixnums."
28 (map 'list
#'check-one-nonneg-fixnum x
))
29 (t (check-one-nonneg-fixnum x
))))
31 (defun check-one-nonneg-fixnum (x)
32 "return value if true, throw error otherwise."
33 (if (and (fixnump x
) (<= 0 x
))
35 (error "Expected non-negative fixnum, but got ~A" x
)))
37 (defun check-one-fixnum (x)
39 (error "not a fixnum - ~a" x
)))
41 (defun check-one-real (a)
42 (if (not (or (rationalp a
) (floatp a
)))
43 (error "not a real number ~s" a
)
46 (defun check-one-number (a)
48 (error "not a number ~s" a
)