Jump to content

Rebol Programming/swap

From Wikibooks, open books for an open world

USAGE:

[edit | edit source]
SWAP series1 series2 

DESCRIPTION:

[edit | edit source]

Swaps elements of a series. (Modifies)

SWAP is a function value.

ARGUMENTS

[edit | edit source]
  • series1 -- (Type: series)
  • series2 -- (Type: series)

SOURCE CODE

[edit | edit source]
swap: func [
    "Swaps elements of a series. (Modifies)" 
    series1 [series!] 
    series2 [series!]
][
    unless any [empty? series1 empty? series2] [
        poke series1 1 also pick series2 1 poke series2 1 pick series1 1
    ] 
    series1
]