Skip to content

Reverse

Status: Stable

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

Description

Reverse[expr] reverses the order of elements in expr.

Examples

No verified examples yet for this function.

Implementation notes

Algorithm. builtin_reverse recurses through the expression with reverse_rec, reversing the argument order at the levels selected by an optional level spec (should_reverse_at_level matches an integer level, or any level listed in a List spec; default is level 1). At each visited node it builds a new function with the same head, drawing children either forward or reversed depending on whether the current level is selected, and recursing into each child.

Attributes: Protected.

Implementation status

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

References

Notes & additional examples

Worked examples

In[1]:= Reverse[{1,2,3}]
Out[1]= {3, 2, 1}

In[2]:= Reverse[{a,b,c,d}]
Out[2]= {d, c, b, a}

Notes

Reverse[expr] reverses the order of top-level elements.