Function: proper-list-p
proper-list-p is a function defined in fns.c.
Signature
(proper-list-p OBJECT)
Documentation
Return OBJECT's length if it is a proper list, nil otherwise.
A proper list is neither circular nor dotted (i.e., its last cdr is nil).
Other relevant functions are documented in the list group.
Probably introduced at or before Emacs version 27.1.
Shortdoc
;; list
(proper-list-p '(1 2 3))
=> 3
(proper-list-p nil)
=> 0
(proper-list-p '(1 . 2))
=> nil
Aliases
format-proper-list-p (obsolete since 27.1)
Source Code
// Defined in /usr/src/emacs/src/fns.c
{
ptrdiff_t len = 0;
Lisp_Object last_tail = object;
Lisp_Object tail = object;
FOR_EACH_TAIL_SAFE (tail)
{
len++;
rarely_quit (len);
last_tail = XCDR (tail);
}
if (!NILP (last_tail))
return Qnil;
return make_fixnum (len);
}