Rebol 程式設計/move
外觀
MOVE source offset /part length /skip size /to
在系列中移動值或值的跨度。
MOVE 是一個函式值。
- 源 -- 源系列(型別:系列)
- 偏移 -- 移動的偏移量,或移動到的索引(型別:整數)
- /part -- 移動系列的一部分
- 長度 -- 要移動的部分的長度(型別:整數)
- /skip -- 將系列視為固定大小的記錄
- 大小 -- 每個記錄的大小(型別:整數)
- /to -- 移動到相對於系列頭的索引
- 捕捉
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
]