< Rebol Programming
USAGE:
MOVE source offset /part length /skip size /to
DESCRIPTION:
Move a value or span of values in a series.
MOVE is a function value.
ARGUMENTS:
- source -- Source series (Type: series)
- offset -- Offset to move by, or index to move to (Type: integer)
REFINEMENTS:
- /part -- Move part of a series
- length -- The length of the part to move (Type: integer)
- /skip -- Treat the series as records of fixed size
- size -- Size of each record (Type: integer)
- /to -- Move to an index relative to the head of the series
(SPECIAL ATTRIBUTES)
- catch
SOURCE CODE
move: func [
"Move a value or span of values in a series."
[catch]
source [series!] "Source series"
offset [integer!] "Offset to move by, or index to move to"
/part "Move part of a series"
length [integer!] "The length of the part to move"
/skip "Treat the series as records of fixed size"
size [integer!] "Size of each record"
/to {Move to an index relative to the head of the series}
][
unless length [length: 1]
if skip [
if 1 > size [throw-error 'script 'out-of-range size]
offset: either to [offset - 1 * size + 1] [offset * size]
length: length * size
]
part: copy/part source length
remove/part source length
insert either to [at head source offset] [
system/words/skip source offset
] part
]
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.