0
내가 사용하고 싶습니다. http://www.rebol.com/docs/words/wfor.html 빨강으로 작동하지 않습니다.for 루프에서 빨간색으로 표시됩니까?
무엇이 해당합니까? Rebol2에서에 대한 으로
내가 사용하고 싶습니다. http://www.rebol.com/docs/words/wfor.html 빨강으로 작동하지 않습니다.for 루프에서 빨간색으로 표시됩니까?
무엇이 해당합니까? Rebol2에서에 대한 으로
그냥 메 자닌, 당신은
for: func [
"Repeats a block over a range of values."
[catch throw]
'word [word!] "Variable to hold current value"
start [number! series! time! date! char!] "Starting value"
end [number! series! time! date! char!] "Ending value"
bump [number! time! char!] "Amount to skip each time"
body [block!] "Block to evaluate"
/local result do-body op
][
if (type? start) <> (type? end) [
throw make error! reduce ['script 'expect-arg 'for 'end type? start]
]
do-body: func reduce [[throw] word] body
op: :greater-or-equal?
either series? start [
if not same? head start head end [
throw make error! reduce ['script 'invalid-arg end]
]
if (negative? bump) [op: :lesser?]
while [op index? end index? start] [
set/any 'result do-body start
start: skip start bump
]
if (negative? bump) [set/any 'result do-body start]
] [
if (negative? bump) [op: :lesser-or-equal?]
while [op end start] [
set/any 'result do-body start
start: start + bump
]
]
get/any 'result
]
에 대한 자신을 쓸 수 있지만, 그물, 예를 들어에서도 몇 강하다 이상의 C-구문 같은 버전을 찾을 수있다 proposal for Rebol3
cfor: func [ ; Not this name
"General loop based on an initial state, test, and per-loop change."
init [block! object!] "Words & initial values as object spec (local)"
test [block!] "Continue if condition is true"
bump [block!] "Move to the next step in the loop"
body [block!] "Block to evaluate each time"
/local ret
] [
if block? init [init: make object! init]
test: bind/copy test init
body: bind/copy body init
bump: bind/copy bump init
while test [set/any 'ret do body do bump get/any 'ret]
]
레드는 또한 자신의 매크로를 정의하고 컴파일 할 수있는 가능성을 제공합니다.