Expand/Shrink

reverse

Definition: sequence res = reverse(sequence src)
Description: Reverse the order of elements in a sequence.
pwa/p2js: Supported.
Comments: A new sequence is created where the top-level elements appear in reverse order compared to the original sequence.
Examples:
string s = "reverse.exw"     ?s -- "reverse.exw"
s[3..6] = reverse(s[3..6])   ?s -- "resreve.exw"
s[4..-7] = reverse(s[4..-7]) ?s -- "reserve.exw"
?reverse({1,3,5,7})             -- {7,5,3,1}
?reverse({{1,2,3}, {4,5,6}})    -- {{4,5,6}, {1,2,3}}
?reverse({99})                  -- {99}
?reverse({})                    -- {}
Implementation: See builtins\misc.e (an autoinclude) for details of the actual implementation.
See Also: append, prepend, repeat
Expand/Shrink