Skip to content

Most

Status: Stable

documented, exercised by the test suite and/or worked examples, with no known limitations recorded.

Description

Most[expr] gives all but the last element of expr.

Examples (4)

Every input below was run against the current Mathilda build and its output recorded.

Basic examples (3)

In[1]:= First[<|"a" -> 10, "b" -> 20|>] In[1b]:= First[<||>, 0] Out[1b]= 0

In[2]:= Rest[<|"a" -> 10, "b" -> 20, "c" -> 30|>]
Out[2]= <|"b" -> 20, "c" -> 30|>

In[3]:= Take[<|"a" -> 1, "b" -> 2, "c" -> 3|>, 2]
Out[3]= <|"a" -> 1, "b" -> 2|>

Applications (1)

In[4]:= Most[{a,b,c,d}]
Out[4]= {a, b, c}

Implementation notes

Algorithm. builtin_most returns a copy of the input with its last element dropped: it copies args 0 .. n−2 into a new function node with the same head. Returns NULL (unevaluated) for atoms or empty expressions.

Attributes: none registered.

References

See also: First, Last, Rest, Take, Drop

Notes & additional examples

Notes

Most[expr] drops the last element; it is the complement of Last.