Re: Handling deep list recursion

milkvetch <[email protected]>
Newsgroups gmane.emacs.help
Message-ID <87y0iq2zhk.fsf@syzygy>
You can just use ‘named-let’ and write the function in a recursive way,
without having to worry about list length.  This is the equivalent of
what you wrote:

(defun alistp (object)
  (named-let recur ((obj object))
    (when (proper-list-p obj)
      (if (atom obj)
	  (eq obj nil)
	(and (consp (car obj))
	     (recur (cdr obj)))))))

Although this doesn't return t only for valid alists; ‘consp’ returns
true for _all_ cons cells, not just (KEY . VALUE) pairs.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.