vectorized math is important
[CommonLispStat.git] / lstypes.lsp
blobf15230c685445cc307ae60529ad825b9591135f6
1 ;;; -*- mode: lisp -*-
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.
7 (defpackage :lisp-stat-types
8 (:use :common-lisp)
9 (:export fixnump check-nonneg-fixnum check-one-fixnum
10 check-one-real check-one-number check-sequence))
12 (in-package #:lisp-stat-types)
15 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16 ;;;;
17 ;;;; Type Checking Functions
18 ;;;;
19 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
21 ;;; Moved out of lsbasics.lsp
23 (defun fixnump (x)
24 "Args: (x)
25 Returns T if X is a fixnum; NIL otherwise."
26 (declare (inline typep))
27 (typep x 'fixnum))
29 (defun check-nonneg-fixnum (x)
30 (if (and (fixnump x) (<= 0 x)) x (error "not a non-negative fixnum")))
32 (defun check-one-fixnum (x)
33 (if (not (fixnump x)) (error "not a fixnum - ~a" x)))
35 (defun check-one-real (a)
36 (if (not (or (rationalp a) (floatp a)))
37 (error "not a real number ~s" a)
38 t))
40 (defun check-one-number (a)
41 (if (not (numberp a))
42 (error "not a number ~s" a)
43 t))
45 (defun check-sequence (a)
46 (if (not (or (vectorp a) (consp a))) (error "not a sequence - ~s" a)))