Jump to content

Rebol Programming/alter

From Wikibooks, open books for an open world

USAGE:

[edit | edit source]
ALTER series value /case 

DESCRIPTION:

[edit | edit source]

If a value is not found in a series, append it; otherwise, remove it. Returns true if added. (Modifies)

ALTER is a function value.

ARGUMENTS

[edit | edit source]
  • series -- (Type: series port)
  • value -- (Type: any)

REFINEMENTS

[edit | edit source]
  • /case -- Case-sensitive comparison

SOURCE CODE

[edit | edit source]
alter: func [
    {If a value is not found in a series, append it; otherwise, remove it. Returns true if added. (Modifies)} 
    series [series! port!] 
    value 
    /case "Case-sensitive comparison"
][
    found? unless remove (
        either case [find/case series :value] [find series :value]
    ) [append series :value]
]