[REBOL] Re: The truth about scope
From: Izkata:Comcast at: 13-Apr-2005 18:57
> Another example that may clarify it more:
>
>>> b: [bla: []]
> == [bla: []]
>>> b2: second b
> == []
>>> insert b2 "hello"
> == []
>>> b
> == [bla: ["hello"]]
>
> This doesn't surprise you, does it?
>
>>> f: func [] [bla: []]
>>> b2: second second :f
> == []
>>> insert b2 "hello"
> == []
>>> source f
> f: func [][bla: ["hello"]]
>
> This is basically the same as above, so if you are surprised just
> stop thinking about it for a second. :)
>
>>> f: func [x] [bla: [] append bla x]
>>> f "hello"
> == ["hello"]
>>> source f
> f: func [x][bla: ["hello"] append bla x]
Ah! That reminds me of something I have been experimenting with...
Quick example:
>> Data: [4 7 2 9]
== [4 7 2 9]
>> New: rejoin [
[ {Here's the data:} newline
[ foreach TMP Data [append {} join TMP { }]
[ newline newline
[ {Here's the data * 5:} newline
[ foreach TMP Data [append {} join TMP * 5 { }]
[ ]
== {Here's the data:
4 7 2 9
Here's the data * 5:
20 35 10 45 }