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

[REBOL] Re: COLLECTing results

From: brett:codeconscious at: 24-Jul-2003 21:26

Thanks Andrew, Gabriele, Volker and Robert for your responses. Latest function below. Andrew wrote:
> Note: compose/deep and: do [(block)]
Sorry Andrew I don't quite understand what you mean. But I have got rid compose completely now :^) Gabriele wrote:
> Small note: you should bind your RESULT word to a fresh context
Thanks for the alert. That prompted me to use USE, but then I realised I would have a potential naming clash. Then I realised I don't need a result variable or special context at all! Collect has gone very minimalistic :^) Volker wrote:
> regarding filtering: there is 'remove-each
Thinking that it is faster to not insert than to insert then remove I modified Collect to include a filter in the most efficient way I knew how. Then I compared the timing of this function with just using Volker's suggestion of removing later using Remove-each. The latter was faster. So I ripped out my filter code again :^) Robert wrote:
> did you had a look at the C++ STL library?
No, I haven't - I don't use C++. Sounds interesting though. Collect is using a code generation approach - I wonder where it can lead. collect: func [ {Collects block evaluations, use as body in For, Repeat, etc.} block [block!] "Block to evaluate." /init result "Initialise the result series." /only "Inserts into result using Only refinement." ] [ result: any [result make block! 100] reduce [ pick [insert insert/only] not only 'tail result 'do :block result ] ] Regards, Brett.