|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 188.8.131.52 184.108.40.206
print reverse/part 220.127.116.11 2 18.104.22.168
|TOC < Back Next >||REBOL.com - WIP Wiki||Feedback Admin|