From 33f03da3b01ca42bdd22ffb023ad7f3d7457a493 Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Sun, 1 Jul 2007 15:21:10 +0300 Subject: [PATCH] ENSURE-CAR --- lists.lisp | 6 ++++++ package.lisp | 1 + 2 files changed, 7 insertions(+) diff --git a/lists.lisp b/lists.lisp index 0a449ba..35565c9 100644 --- a/lists.lisp +++ b/lists.lisp @@ -126,6 +126,12 @@ recommended for performance intensive use. Main usefullness as the expected-type designator of a TYPE-ERROR." `(satisfies circular-list-p)) +(defun ensure-car (thing) + "If THING is a CONS, its CAR is returned. Otherwise THING is returned." + (if (consp thing) + (car thing) + thing)) + (defun ensure-cons (cons) "If CONS is a cons, it is returned. Otherwise returns a fresh cons with CONS in the car, and NIL in the cdr." diff --git a/package.lisp b/package.lisp index 76997ed..122c27a 100644 --- a/package.lisp +++ b/package.lisp @@ -40,6 +40,7 @@ #:circular-list #:circular-list-p #:circular-tree-p + #:ensure-car #:ensure-cons #:ensure-list #:lastcar -- 2.11.4.GIT