[EMAIL PROTECTED] wrote:
> 
> >> make-adder: func [x] [ func [y] [+ x  y] ]
> >> adder1: make-adder 6
> >> adder1 5
> == 11
> 
> This is way cool.
> 
> But now, this doesn't work.
> 
> >> make-adder 6 5
> == 5
> >> (make-adder 6) 5
> == 5
> >> ((make-adder 6) 5)
> == 5
> 
> I sort of understand that.

make-adder returns a function, but the function isn't evaluated, and 5
is the last datatype on the line, so it returns that.

> >> do make-adder 6 5
> == 11

That is similar to 'do :adder1 5'

>> reduce [make-adder 6 5]
== [func [y][+ x y] 5]
>> type? first reduce [make-adder 6 5]
== function!

>> reduce [:adder1 5]
== [func [y][+ x y] 5]
>> reduce reduce [:adder1 5]
== [11]

After the first reduce, you have a function! and an integer!.  With the
second reduce, rebol evaluates the function.  Hope that makes things a
bit clearer :)

Julian Kinraid

Reply via email to