# 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
Technicalia | Previous versions had a from_to parameter which has been removed, and there are no equivalents for Eu’s pFrom and (0-based) pTo: just replace "s = reverse(s,{i,j})" with "s[i..j] = reverse(s[i..j])" in any rare cases said were used. buultins/utfconv.e also contains the commented-out, untested, and as yet undocumented function unicode_reverse(), which will or at least should reverse a unicode string while preserving combining characters.