Path: utzoo!utgpu!water!watmath!clyde!att!rutgers!cmcl2!yale!Krulwich-Bruce From: Krulwich-Bruce@cs.yale.edu (Bruce Krulwich) Newsgroups: comp.lang.lisp Subject: Re: list-length vs. listp in Common Lisp? Message-ID: <37215@yale-celray.yale.UUCP> Date: 6 Sep 88 19:47:06 GMT References: <6317@orstcs.CS.ORST.EDU> Sender: root@yale.UUCP Reply-To: Krulwich-Bruce@cs.yale.edu (Bruce Krulwich) Organization: Computer Science, Yale University, New Haven, CT 06520-2158 Lines: 21 In-reply-to: ruffwork@orstcs.CS.ORST.EDU (Ritchey Ruff) In article <6317@orstcs.CS.ORST.EDU>, ruffwork@orstcs (Ritchey Ruff) writes: >Anyone notice how hard it is to make sure you pass a "true" >list to list-length (or length)? The only way I've found to make sure an >arg is a true list is with - > (defun true-listp (l) > (and (listp sexp) > (null (cdr (last l))))) ... >it would be nice if you could do something like > (list-length sexp :doted-ending-allowed) >Isn't there an easier way? (now watch, even though I just spent over >an hour pouring through Steele somebody will say, "Oh, that's >the function called true-listp on page xyz of CLtL...;-). Well, regardless of whether TRUE-LISTP is built in or user-written, it will still be slower to do this because the list will end up traversed twice. The only way to avoid this inefficiency is to write your own LIST-LENGTH that has options to deal with a dotted ending (or to try to get such options added to the CL standard). Bruce