< Rebol Programming  
        
      USAGE:
COLLECT-WORDS block /deep /set /ignore words
DESCRIPTION:
Collect unique words used in a block (used for context construction).
COLLECT-WORDS is a function value.
ARGUMENTS
- block -- (Type: block)
 
REFINEMENTS
- /deep -- Include nested blocks
 - /set -- Only include set-words
 - /ignore -- Ignore prior words
- words -- Words to ignore (Type: object port block)
 
 
SOURCE CODE
collect-words: func [
    {Collect unique words used in a block (used for context construction).} 
    block [block!] 
    /deep "Include nested blocks" 
    /set "Only include set-words" 
    /ignore "Ignore prior words" 
    words [object! port! block!] "Words to ignore" 
    /local rule word blk w
][
    deep: either deep [[path! | set-path! | lit-path! | into rule]] [any-block!] 
    word: either set [set-word!] [any-word!] 
    blk: [] 
    parse block rule: [
        set w word (insert tail blk to-word to-string w) | deep | skip
    ] 
    also either ignore [
        unless block? words [words: words-of words] 
        difference blk intersect blk words
    ] [
        unique blk
    ] (clear blk set [block words] none)
]
    This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.