REBOL Programming/alter

From Wikibooks, open books for an open world
< REBOL Programming
Jump to: navigation, search

USAGE:[edit]

ALTER series value /case 

DESCRIPTION:[edit]

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]

  • series -- (Type: series port)
  • value -- (Type: any)

REFINEMENTS[edit]

  • /case -- Case-sensitive comparison

SOURCE CODE[edit]

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]
]