Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: skip a value inside 'foreach

From: lmecir:mbox:vol:cz at: 16-Nov-2002 16:33

Hi Halvard, you can use e.g. cfor [i: 1] [i <= 3] [i: i + 1] [ if i = 2 [continue] print i ] -L The CFOR function is (much) faster, than FOR and here is its implementation: set-words: function [ {Get all set-words from a block} block [block!] ] [elem words] [ words: make block! length? block parse block [ any [ set elem set-word! ( insert tail words to word! :elem ) | skip ] ] words ] cfor: function [ {a C-like for function} [throw] init [block!] test [block!] inc [block!] body [block!] ] [use-words cont] [ use-words: append set-words init [continue] body: append reduce [:catch body] inc cont: reduce [does [throw none]] use use-words reduce [ :set [continue] cont :do init :while test body ] ]