Last modified on 27 October 2012, at 22:08

REBOL Programming/forskip

USAGE:Edit

FORSKIP 'word skip-num body 

DESCRIPTION:Edit

Evaluates a block for periodic values in a series.

FORSKIP is a function value.

ARGUMENTSEdit

  • word -- Word set to each position in series and changed as a result (Type: word)
  • skip-num -- Number of values to skip each time (Type: integer)
  • body -- Block to evaluate each time (Type: block)

(SPECIAL ATTRIBUTES)Edit

  • throw
  • catch

SOURCE CODEEdit

forskip: func [
    "Evaluates a block for periodic values in a series." 
    [throw catch] 
    'word [word!] {Word set to each position in series and changed as a result} 
    skip-num [integer!] "Number of values to skip each time" 
    body [block!] "Block to evaluate each time" 
    /local orig result
][
    if not positive? skip-num [throw make error! join [script invalid-arg] skip-num] 
    if not any [
        series? get word 
        port? get word
    ] [throw make error! {forskip/forall expected word argument to refer to a series or port!}] 
    orig: get word 
    while [any [not tail? get word (set word orig false)]] [
        set/any 'result do body 
        set word skip get word skip-num 
        get/any 'result
    ]
]