Skip to content
angerangel edited this page Mar 19, 2013 · 1 revision

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 (modified) (series!)
  • offset -- Offset to move by, or index to move to (integer!)

REFINEMENTS

  • /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
] ]
Clone this wiki locally