std-list-length | ![]() |
Returns the length of the list or nil if the argument is no list. This version is basically the same as the standard function LENGTH
, but it doesn't fail on dotted pairs, on so-called not-proper lists. It is quite slow but must be used instead of LENGTH
or VL-LIST-LENGTH
if there might occur non-proper lists, just as parsing arbitrary input or the symbol table.
Note
VL-LIST-LENGTH
or VLX-LIST-LENGTH
returns nil on not-proper lists.
LENGTH
fails on not-proper lists.
(std-list-length 1) => nil (std-list-length nil) => 0 (std-list-length '(0 1 2 0)) => 4 (std-list-length '(0 1 2 0 1)) => 5 (std-list-length '(0 1 2 0 . 1)) => 4 (std-list-length '(0 1 2 (0 . 1))) => 4 (std-list-length '(0 1 2 0 . (1))) => 5 (vl-list-length '(0 1 2 0 . 1)) => nil (length '(0 1 2 0 . 1)) Error: bad list
lst: any list, including not proper lists
A non-negative integer number or nil
None.
(std-require 'STDLIST)
Defined in STDLIST