Last modified on 31 October 2012, at 14:04

REBOL Programming/move

USAGE:Edit

MOVE source offset /part length /skip size /to 

DESCRIPTION:Edit

Move a value or span of values in a series.

MOVE is a function value.

ARGUMENTS:Edit

  • source -- Source series (Type: series)
  • offset -- Offset to move by, or index to move to (Type: integer)

REFINEMENTS:Edit

  • /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)Edit

  • catch

SOURCE CODEEdit

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
]