WOLFRAM

Enable JavaScript to interact with content and submit forms on Wolfram websites. Learn how
Wolfram Language & System Documentation Center

Length [expr]

gives the number of elements in expr.

Details
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Generalizations & Extensions  
Applications  
Properties & Relations  
Possible Issues  
See Also
Tech Notes
Related Guides
Related Links
History
Cite this Page

Length

Length [expr]

gives the number of elements in expr.

Details

Examples

open all close all

Basic Examples  (2)

Find the length of a list:

Find the length of an Association :

Scope  (2)

Length works with any head:

Length [expr] gives the number of elements in the top level of expr:

Generalizations & Extensions  (5)

The length of a symbol is 0:

The length of a string is 0:

StringLength gives the number of characters:

Explicit numbers have length 0:

Length works on SparseArray objects:

Length works on structured arrays, like SymmetrizedArray objects:

Applications  (5)

Find the number of rows in a matrix:

Find the length of each sublist:

Find the number of terms in a polynomial:

Find the number of digits in 1000!:

Get the number of points used to plot a curve:

Properties & Relations  (2)

Length gives the maximum index that can be used:

For expressions with length greater than 0, Length [expr] equals First [Dimensions [expr]]:

Possible Issues  (5)

Length operates on the FullForm of expressions, not their displayed form:

Rational and complex numbers are atoms, so they have length 0:

Numeric expressions are treated like other expressions, not like explicit numbers:

Length counts only "arguments", not parts of heads:

For nonatomic e, Length [e] is equivalent to First [Dimensions [e]]:

History

Introduced in 1988 (1.0) | Updated in 2003 (5.0) 2014 (10.0)

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

Text

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

CMS

Wolfram Language. 1988. "Length." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/Length.html.

APA

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

BibTeX

@misc{reference.wolfram_2025_length, author="Wolfram Research", title="{Length}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/Length.html}", note=[Accessed: 05-December-2025]}

BibLaTeX

@online{reference.wolfram_2025_length, organization={Wolfram Research}, title={Length}, year={2014}, url={https://reference.wolfram.com/language/ref/Length.html}, note=[Accessed: 05-December-2025]}

Top [フレーム]

AltStyle によって変換されたページ (->オリジナル) /