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

collect-in

 [1/4] from: rotenca::telvia::it at: 11-Dec-2003 15:36


This is my idea of collect: collect-in: func [ {Append block evaluations to a series, use as body in For, Repeat, etc.} dest [block! hash! list! any-string!] "Series to append results" block [block!] "Block to evaluate." /only "Inserts into dest using the Only refinement." /local main ][ change/only change change second main: func [res [any-type!]][ none none none get/any 'res get/any 'res ] pick [insert insert/only] not only 'tail dest reduce [:main to-paren block] ] ;Usage: dest: make block! 100 repeat n 10 collect-in dest [n * 100] The advantages: is trasparent for break works with empty block inside the body you know where values are stored is not slow I should like to submit it the view 1.3 project What do you think? --- Ciao Romano

 [2/4] from: rotenca:telvia:it at: 11-Dec-2003 20:30


A curiosity, i have compressed rebol.exe with http://upx.sourceforge.net/ i becomes 320 kb and seems to works How small can become Core? --- Ciao Romano

 [3/4] from: lmecir:mbox:vol:cz at: 12-Dec-2003 17:14


Romano Paolo Tenca napsal(a):
>This is my idea of collect: >collect-in: func [
<<quoted lines omitted: 23>>
>Ciao >Romano
Does this behave well w.r.t. Return? -L

 [4/4] from: rotenca:telvia:it at: 13-Dec-2003 14:30


Hi Ladislav,
> >The advantages: > > is trasparent for break > > works with empty block > > inside the body you know where values are stored > > is not slow > Does this behave well w.r.t. Return?
Should be trasparent for return. Also the value returned by the loop is the same. The body block is executed in the original environment, only it is copied by to paren! paren! is not supported for dest series. Follow a more readable version: collect-in: func [ {Append block evaluations to a series, use as body in For, Repeat, etc.} dest [block! hash! list! any-string!] "Series to append results" block [block!] "Block to evaluate." /only "Inserts values into dest using /only." /local main ][ insert second main: func [res [any-type!]][get/any 'res -1] reduce [ 'pick pick [insert insert/only] not only 'tail dest ] reduce [:main to-paren block] ] --- Ciao Romano

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted