List Manipulation Functions Reference (AutoLISP)

The following table provides summary descriptions of the AutoLISP list manipulation functions.

List manipulation functions

Function

Description

(acad_strlsort lst)

Sorts a list of strings by alphabetical order

(append lst ...)

Takes any number of lists and runs them together as one list

(assoc item alist)

Searches an association list for an element and returns that association list entry

(caddr lst)

Returns the third element of a list

(cadr lst)

Returns the second element of a list

(car lst)

Returns the first element of a list

(cdr lst)

Returns the specified list, except for the first element of the list

(cons new-first-element lst)

The basic list constructor

(foreach name lst [expr ...])

Evaluates expressions for all members of a list

(last lst)

Returns the last element in a list

(length lst)

Returns an integer indicating the number of elements in a list

(list [expr ...])

Takes any number of expressions and combines them into one list

(listp item)

Verifies that an item is a list

(mapcar function list1 ... listn)

Returns a list of the result of executing a function with the individual elements of a list or lists supplied as arguments to the function

(member expr lst)

Searches a list for an occurrence of an expression and returns the remainder of the list, starting with the first occurrence of the expression

(nth n lst)

Returns the nth element of a list

(reverse lst)

Returns a list with its elements reversed

(subst newitem olditem lst)

Searches a list for an old item and returns a copy of the list with a new item substituted in place of every occurrence of the old item

(vl-consp list-variable)

Determines whether or not a list is nil

(vl-every predicate-function list [ more-lists ...])

Checks whether the predicate is true for every element combination

(vl-list* object [more-objects ...])

Constructs and returns a list

(vl-list->string char-codes-list)

Combines the Unicode characters associated with a list of integers into a string

(vl-list-length list-or-cons-object)

Calculates list length of a true list

(vl-member-if predicate-function list)

Determines whether the predicate is true for one of the list members

(vl-member-if-not predicate-function list)

Determines whether the predicate is nil for one of the list members

(vl-position symbol list)

Returns the index of the specified list item

(vl-remove element-to-remove list)

Removes elements from a list

(vl-remove-if predicate-function list)

Returns all elements of the supplied list that fail the test function

(vl-remove-if-not predicate-function list)

Returns all elements of the supplied list that pass the test function

(vl-some predicate-function list [more-lists ...])

Checks whether the predicate is not nil for one element combination

(vl-sort list comparison-function)

Sorts the elements in a list according to a given compare function

(vl-sort-i list comparison-function)

Sorts the elements in a list according to a given compare function, and returns the element index numbers

(vl-string->list string)

Converts a string into a list of Unicode character codes