< Rebol Programming
USAGE:
FORSKIP 'word skip-num body
DESCRIPTION:
Evaluates a block for periodic values in a series.
FORSKIP is a function value.
ARGUMENTS
- 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)
- throw
- catch
SOURCE CODE
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
]
]
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.