[REBOL] Re: 'get'ing a 'word from a block
From: tim:johnsons-web at: 31-Dec-2002 21:47
Thank you Anton! I forgot about 'bind.
I'm still in the dark a bit though, because
I really want to get the values for 'a 'b 'c
If I rewrite test as :
test: func [row [block!]][?? row ?? a]
>> foreach :d blk code: [
[ ?? a ?? b ?? c
[ test reduce bind d 'a
row: [1 2 3]
** Script Error: a has no value
** Where: rejoin
** Near: mold name: get name
If possible, I would want to get
'row as [a b c]
and 'get 1 from a.
Is this possible?
And Happy New Year!
* Anton <[anton--lexicon--net]> [021231 21:10]:
> Your block d contains three words, a b c, whose
> context is... in that block... (I think).
> You need to bind the words in the d block into
> the foreach's context (which we can get to using
> 'a as an example word in that context.)
> Having bound the words in d to the foreach context,
> they are still simply [a b c], so you need to
> reduce the block get a block of values out.
> So a bit of binding and reducing and you are fixed:
> d: [a b c]
> blk: [1 2 3 4 5 6 7 8 9]
> test: func [row [block!]][?? row]
> foreach :d blk code: [
> ?? a ?? b ?? c
> test reduce bind d 'a
> > Hello Rebols:
> > I have an example below where foreach sets a block
> > of values, but I don't know how to retain those
> > values within the block when I pass the block to
> > another function:
> > >> d: [a b c]
> > == [a b c]
> > >> blk: [1 2 3 4 5 6 7 8 9]
> > == [1 2 3 4 5 6 7 8 9]
> > >> test: func[row[block!]][?? row ?? a]
> > >> foreach :d blk[?? a ?? b ?? c test d]
> > a: 1
> > b: 2
> > c: 3
> > ; foreach sets the values in the block correctly
> > row: [a b c]
> > ; the words are passed in the block to 'test
> > ** Script Error: a has no value
> > ** Where: rejoin
> > ** Near: mold name: get name
> > ; alas, can't get the value
> > What am I doing wrong here?
> > TIA
> > --
> > Tim Johnson <[tim--johnsons-web--com]>
> To unsubscribe from this list, please send an email to
> [rebol-request--rebol--com] with "unsubscribe" in the
> subject, without the quotes.
Tim Johnson <[tim--johnsons-web--com]>