reverse, reversed
- keyword
- sort in reverse order -- synonym for descending
- sort reversed
- repeat in reverse order (new in 2.03)
- function
- new in 2.03
- The reverse function returns a string or a list in reverse order. If reverse is called with a parameter that is a list or range, the value returned will be a list or range in the opposite order. Otherwise the parameter is treated as a string and the characters of the string are reversed:
put reverse("abcd") —> "dcba"
put the reverse of A to Z —> Z to A
put reverse of ["dog","cat","toad"] —> ["toad","cat","dog"]
The function can also be called using a reversed syntax:
put [1,3,46,9,5] reversed —> [5,9,46,3,1]
put "goldenrod" reversed —> "dornedlog"
- command
- new in 2.03
- The reverse command will reverse the elements of a container. If called with a variable or other container, its contents are reversed directly. Otherwise the result of the reverse operation is assigned to the variable
it
:
reverse "ABCD" — (not a container, so result goes into 'it')
put it —> "DCBA"
set myList to [3,4,5,6,7,8]
reverse myList
put myList —> [8,7,6,5,4,3]
reverse the lines of fileContents
- Related: shuffle