[REBOL] Re: Clunky-looking code
From: gjones05:mail:orion at: 7-Apr-2001 10:01
From: "Harold Grovesteen"
> Can someone explain exactly what this code is doing? I'm confused by
> this usage of ":" and its relationship to a block.
> [Sanghabum--aol--com] wrote:
>
> > Thanks Renaud,
> >
> > <Renaud>
> > MultiplyBlocks: func [
> > Block1 Block2
> > /local sum
> > ][
> > sum: 0
> > repeat i min length? Block1 length? Block2 [
> > sum: sum + (Block1/:i * Block2/:i)
> > ]
> > return sum
> > ]
> > </Renaud>
Hi, Harold,
Using the colon before a word retrieves its value. In the case where it is
used as a part of a path, then the value serves as an index.
A different example:
a: [cat dog]
:a ;returns the value of the word a, which is the block
a/1 ;returns cat
i: 1
a/:i ;returns cat
Hope this helps.
--Scott Jones