Last
Examples
open all close allBasic Examples (5)
Extract the last element of a list:
Last[{a, b, c}]Extract the last row of a matrix:
Last[{{a, b}, {c, d}, {e, f}}]Extract the last element of an association:
Last[<|1 -> a, 2 -> b|>]The head need not be List:
Last[a ^ 2 + b ^ 2]Return x if there are zero elements:
Last[{}, x]Last[{a, b}, x]Generalizations & Extensions (1)
Last works on SparseArray objects:
Last[SparseArray[Range[100]]]Properties & Relations (1)
Last[expr] is equivalent to expr[[-1]]:
Last[{a, b, c}]{a, b, c}[[-1]]Tech Notes
Related Guides
History
Introduced in 1988 (1.0) | Updated in 2014 (10.0) ▪ 2015 (10.3)
Text
Wolfram Research (1988), Last, Wolfram Language function, https://reference.wolfram.com/language/ref/Last.html (updated 2015).
CMS
Wolfram Language. 1988. "Last." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/Last.html.
APA
Wolfram Language. (1988). Last. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Last.html
BibTeX
@misc{reference.wolfram_2026_last, author="Wolfram Research", title="{Last}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/Last.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_last, organization={Wolfram Research}, title={Last}, year={2015}, url={https://reference.wolfram.com/language/ref/Last.html}, note=[Accessed: 12-June-2026]}