Script Library: 1238 scripts
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Discussion posts for script collect.r

1
greggirwin
10-Jan-2006 21:34
I've had this function for quite a while, and various forms of it 
to boot. There are versions that don't use a set-word! syntax, versions 
that use an internal function as the replacement code in the block, 
and more. This (set-word!) is the syntax I've found I prefer.


The basic idea is simple, anywhere in the block the WORD parameter 
appears as a set-word!, the set-word! will be changed to a bit of 
code that "collects" the value assigned there. It's proven quite 
flexible and easy to use for me, though I was initially concerned 
about overriding the meaning of set-words this way. I think the semantic 
meaning maps well to its use here, as long as you're aware going 
in that it's a dialected function--a very light dialect to be sure, 
but a dialect none-the-less.

I'm sure there are other solutions, but I'm very happy not writing:

    result: copy []
    foreach ...
        append result value
    result


all over the place any more. I think it also makes the code much 
clearer, because it says you're collecting values, and whereever 
you see the target word, you know it's being collected.


I'd like to see something like this included in REBOL, but it doesn't 
have to be this one. The original collector idea came from Brett 
Handley, then Romano Paolo Tenca added his touch to it, and I put 
quite a different spin on it after that.
2
sumnerzzupa
24-May 3:53
REBOL

about overriding the meaning of set-words this way.

It's proven quite flexible and easy to use for me, though I was initially concerned

Contents:

Turf Installation

MakeDoc2 by REBOL- 24-May-2021
3
baum
12-Aug 23:41

I'm a Programming Historian writing my blog articles and assignments for university students on https://www.writemyessayfast.ca/about the comprehensive R archive network and its features for dummies. Garrett Grolemund taught me the Data Science with R. And since then I've been spending time only on scripts and custom tasks.

4
marosol
1-Sep 22:52
REBOL

Thank you for sharing this article. Keep it up. | Fencing

Contents:

MakeDoc2 by REBOL- 1-Sep-2021