forked from rebol/rebol
-
Notifications
You must be signed in to change notification settings - Fork 2
Move
angerangel edited this page Mar 19, 2013
·
1 revision
MOVE source offset /part length /skip size /to
Move a value or span of values in a series.
MOVE is a function value.
- source -- Source series (modified) (series!)
- offset -- Offset to move by, or index to move to (integer!)
-
/part -- Move part of a series
- length -- The length of the part to move (integer!)
-
/skip -- Treat the series as records of fixed size
- size -- Size of each record (integer!)
- /to -- Move to an index relative to the head of the series
#SOURCE
move: make function! [ [
"Move a value or span of values in a series."
source [series!] "Source series (modified)"
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 [cause-error 'script 'out-of-range size]
offset: either to [offset - 1 * size + 1] [offset * size]
length: length * size
]
part: take/part source length
insert either to [at head source offset] [
lib/skip source offset
] part
] ]