std-not-proper-list-p


Synopsis

(std-not-proper-list-p <expr>)

Description

Predicate if the expression is a list which last cons cell is not nil, which is misinterpretably also called "dotted list".

Such as '(0 1 . 2)

We also call it sometimes "bad lists" because such lists may not be used for some system functions which accepts only correct lists, like MEMBER, LENGTH, LAST, FOREACH, APPLY, MAPCAR, REVERSE, ...

Why do we call it STD-NOT-PROPER-LIST-P instead of STD-DOTTED-LIST-P?

Every single list may be expressed as dotted list because of its recursive definition. Normal lists written without dots are in fact special cases of dotted lists. But with dotted lists you usually combine dotted pairs.

E.g.: (a . (b . (c . nil))) prints as (a b c)

Why not-proper?

These lists are not suitable to traversal lists functions like LENGTH, LAST, MAPCAR, FOREACH, APPLY, REVERSE, .... Every function that expects a list (or nil) as cdr of any list. They raise the error "bad list".

Normal lists like (0 1 2) may be written in dotted notation like (0 1 2 . nil). This is similar to the internal memory cell representation.

Note

"Not proper lists" or so-called "bad lists" are easily created with the Visual Lisp builtin function vl-list* (in Vital Lisp vlx-list*) if the last argument is an atom: (list* <expr>... <atom>) and not a list.

Examples

(std-not-proper-list-p 0) => nil
(std-not-proper-list-p '(0 . 1)) => T
(std-not-proper-list-p '((0 . 1))) => nil
(std-not-proper-list-p '(0 1 . 2)) => T

Note

Cyclic lists are bad lists too, but they are not possible to create with today's AutoLISP, because destructive list functions like rplaca and rplacd are not available. Cyclic lists would result in an endless loop if they are traversed with not suitable list functions.

Arguments

expr: any valid lisp expression

Return Value

T or nil.

Side Effects

None.

Module

(std-require 'STDLIST)

Defined in STDLIST