Hi,

> Hi Jeff
>
> You wrote:
> >   save-em: copy []
> >   make-adder: func [x][
> >       get in last append save-em make object! [
> >           z: x f: func [y][+ z y]
> >       ] 'f
> >   ]
> >
> >   The above creates new contexts to hold the different values
> >   of X in your separate add functions.  (It also creates new
> >   functions that use those X values).
>
> Nice and it works.
>
> One can also tidy things up by encapsulating the block of saved
items in the
> function which also illustrates a practical use of the behavior
of literal
> blocks contained in functions.
>
> make-add: func [x][
>      saved: []
>      get in last append saved make object! [
>          z: x
>          f: func [y][+ z y]
>      ] 'f
> ]
>
> Cheers
>
> -Larry
>
>

an even more tidy approach is to use www.rebol.org/general/sfun.r

 make-add: func [x][
      sfun [z: x] [y][+ z y]
]

Ladislav

Reply via email to