# Listable

is an attribute that can be assigned to a symbol to indicate that the function should automatically be threaded over lists that appear as its arguments.

# Details

• Listable functions are effectively applied separately to each element in a list, or to corresponding elements in each list if there is more than one list.
• Most builtin mathematical functions are Listable. »
• All the arguments which are lists in a Listable function must be of the same length. »
• Arguments that are not lists are copied as many times as there are elements in the lists.

# Examples

open allclose all

## Basic Examples(4)

A Listable function threads over its list argument:

Log is listable:

Listable functions combine corresponding elements:

Arguments that are not lists are replicated as needed:

## Scope(4)

Define a function to be listable:

Most built-in mathematical functions are listable:

Listability works for any nesting depth of lists:

The nesting level of the different arguments need not be the same:

Listability works on other list-like constructs such as SparseArray:

## Applications(2)

To apply a function to a vector, take advantage of Listable functions when possible:

Use the listability of Plus, Power, Sin, and Times:

Use Map:

Use Table:

Use Table and Part to access elements of v as might be done in a lower-level language:

The results are the same up to numerical roundoff:

Use efficient sparse arithmetic to numerically solve the heat equation :

Matrix for a second-order approximation to the second derivative on the grid :

Incorporate Dirichlet boundary conditions to form the Jacobian J:

The sparse identity matrix:

Form sparse matrix for using the listability of arithmetic:

LU decomposition of in a functional form:

Step initial condition on spatial grid x using the listability of UnitStep:

Get the solution at , using the backward Euler method:

## Properties & Relations(7)

Listable, in general, functions effectively apply Thread many times:

Applying listable functions to several arrays of equal dimension is equivalent to using MapThread:

Listable functions applied to several arrays require overlapping dimensions to be equal:

Arguments with equal dimensions:

Arguments with equal overlapping dimensions, i.e. {2} has the same leading dimensions as {2,3}:

Arguments with unequal overlapping dimensions, i.e. {2} does not have the same leading dimensions as {3,2}:

Listable functions applied to arrays can be written as a Table:

Let :

In general, :

A function implemented in terms of a listable operation may not need the Listable attribute:

The system symbols with the Listable attribute:

More than half these are arithmetic functions possessing the NumericFunction attribute as well:

The products given by Dot, Times, and KroneckerProduct are inner, element-wise, and outer:

The inner product of two vectors:

The vector resulting from the product of corresponding elements:

The matrix resulting from the outer product of the vectors:

## Possible Issues(1)

All list arguments must have the same length:

Wolfram Research (1988), Listable, Wolfram Language function, https://reference.wolfram.com/language/ref/Listable.html.

#### Text

Wolfram Research (1988), Listable, Wolfram Language function, https://reference.wolfram.com/language/ref/Listable.html.

#### CMS

Wolfram Language. 1988. "Listable." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Listable.html.

#### APA

Wolfram Language. (1988). Listable. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Listable.html

#### BibTeX

@misc{reference.wolfram_2024_listable, author="Wolfram Research", title="{Listable}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/Listable.html}", note=[Accessed: 17-June-2024 ]}

#### BibLaTeX

@online{reference.wolfram_2024_listable, organization={Wolfram Research}, title={Listable}, year={1988}, url={https://reference.wolfram.com/language/ref/Listable.html}, note=[Accessed: 17-June-2024 ]}