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.
10 (defpackage :lisp-stat-types
11 (:documentation
"Provides some typeing for LispStat, but is clearly
14 (:export fixnump check-nonneg-fixnum check-one-fixnum
15 check-one-real check-one-number
))
17 (in-package :lisp-stat-types
)
19 ;;; Type Checking Functions
20 ;;; (Moved out of lsbasics.lsp, placed there by initial design).
25 Returns T if X is a fixnum; NIL otherwise."
26 (declare (inline typep
))
29 (defun check-nonneg-fixnum (x)
30 "Ensure that x or all elts of x are non-negative fixnums."
31 (cond ((typep x
'sequence
) ;; seq rather than list, allows for vector?
32 (map 'list
#'check-one-nonneg-fixnum x
))
33 (t (check-one-nonneg-fixnum x
))))
35 (defun check-one-nonneg-fixnum (x)
36 "return value if true, throw error otherwise."
37 (if (and (fixnump x
) (<= 0 x
))
39 (error "Expected non-negative fixnum, but got ~A" x
)))
41 (defun check-one-fixnum (x)
43 (error "not a fixnum - ~a" x
)))
45 (defun check-one-real (a)
46 (if (not (or (rationalp a
) (floatp a
)))
47 (error "not a real number ~s" a
)
50 (defun check-one-number (a)
52 (error "not a number ~s" a
)