Listable

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  (3)

Log is listable:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Listable functions combine corresponding elements:

In[1]:=
Click for copyable input
Out[1]=

Arguments that are not lists are replicated as needed:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Scope  (3)

Generalizations & Extensions  (1)

Applications  (2)

Properties & Relations  (4)

Possible Issues  (1)

See Also

Thread  Map  Sequence  SparseArray  MatrixFunction

Tutorials

Introduced in 1988
(1.0)