|REBOL 3 Docs||Guide||Concepts||Functions||Datatypes||Errors|
|TOC < Back Next >||Updated: 3-Aug-2010 Edit History|
Reverses a series and similar types. (Modifies)
series [series! gob! tuple! pair!]
/part - Limits to a given length or position
length [number! series!]
Reverses the order of elements in a series or tuple.
blk: [1 2 3 4 5 6] reverse blk print blk 6 5 4 3 2 1
The /PART refinement reverses the specified number of elements from the current index forward. If the number of elements specified exceeds the number of elements left in the series or tuple, the elements from the current index to the end will be reversed.
text: "It is possible to reverse one word in a sentence." reverse/part (find text "reverse") (length? "reverse") print text It is possible to esrever one word in a sentence.
Note that reverse returns the starting position it was given. (This change was made to newer versions.)
blk: [1 2 3 4 5 6] print reverse/part blk 4 4 3 2 1 5 6
Reverse also works for pairs and tuples:
print reverse 10x20 print reverse 1.2.3 3.2.1
For tuple values the current index cannot be moved so the current index is always the beginning of the tuple.
print reverse 22.214.171.124 126.96.36.199
print reverse/part 188.8.131.52 2 184.108.40.206
|TOC < Back Next >||REBOL.com - WIP Wiki||Feedback Admin|