[REBOL] Re: Mapping series
From: volker::nitsch::gmail::com at: 8-Mar-2006 22:40
On 3/8/06, Jeff Massung <massung-gmail.com> wrote:
> Thanks, I'll take a closer look at that one when I get a moment. Along the
> same lines, has anyone come up with a version of "gensym" that can be used?
> For example, using VID, I may want to dynamically create controls that
> access themselves.
if they want to access themself, they are objects, they know who they
are. Means they have a 'self.
Except if you use action-blocks in vid, these are closures, staying
bound to their original environment. They get the appropriate face as
> I currently don't know of a way to do this without
> generating a symbol to use. Here's a brief example of what I mean:
> dyn-btn: does [
> join  [ gensym: 'button "foo" [ gensym/text: "bar" ]
> Obviously, however, I can't use "gensym:" over and over again,
Not?! Looking confused for context.
Maybe not elegant example, but still possible :)
The basic trick with making a context and getting a word from it is universal.
dyn-btn: func[foo /local ctx] [
lay: compose copy/deep [
sym: button (foo) [ probe sym/text probe lay ]
repeat i 10[
append buttons ctx: dyn-btn join "btn" i
append lay ctx/lay
lay: layout lay
foreach btn buttons[
> I need to
> have a way of "creating" the symbol on the fly and accessing it. I suppose I
> could use to-word and coerce a generated string for the name (like Lisp
> does). But is there a "nicer" way to do this?
> On 3/8/06, Gregg Irwin <greggirwin-mindspring.com> wrote:
> > Hi Jeff,
> > JM> So, I'm sure REBOL has some sort of support for this, but I have yet
> > to find
> > JM> it. Does REBOL have any built-in support for traditional mapping
> > functions
> > JM> that are found in Lisp?
> > Oddly enough, there isn't a native one. It has come up a number of
> > times, and many folks have written their own; I don't know why RT
> > hasn't included one yet. It's possible they're still looking for the
> > right design. e.g. with refinements and such, I think there's more to
> > it than just do the same thing Lisp does, when creating a standard
> > function.
> > Here's one, written by Larry Palmiter, that I use sometimes:
> > map: apply: func [fn blk args /local result][
> > result: copy 
> > repeat el blk [append/only result fn :el args]
> > result
> > ]
> > -- Gregg
> > --
> > To unsubscribe from the list, just send an email to
> > lists at rebol.com with unsubscribe as the subject.
> To unsubscribe from the list, just send an email to
> lists at rebol.com with unsubscribe as the subject.
Any problem in computer science can be solved with another layer of
indirection. But that usually will create another problem.