SETF-functions for lastcar, first-elt, and last-elt. :KEY and :TEST for starts-with...
[alexandria.git] / types.lisp
blob8182e12ff1deee2f63cf347bcefa25411436fb02
1 (in-package :alexandria)
3 (declaim (inline of-type))
4 (defun of-type (type)
5 "Returns a function of one argument, which returns true when its argument is
6 of TYPE."
7 (lambda (thing) (typep thing type)))
9 (declaim (inline type=))
10 (defun type= (type1 type2)
11 "Returns a primary value of T is TYPE1 and TYPE2 are the same type,
12 and a secondary value that is true is the type equality could be reliably
13 determined: primary value of NIL and secondary value of T indicates that the
14 types are not equivalent."
15 (multiple-value-bind (sub ok) (subtypep type1 type2)
16 (cond ((and ok sub)
17 (subtypep type2 type1))
18 (ok
19 (values nil ok))
21 (multiple-value-bind (sub ok) (subtypep type2 type1)
22 (values nil ok))))))