jeff wrote:
> 1. Can you simulate a static local variable in REBOL? The variable
should be local to a function, but each time the function is called, the
variable has the same value it had at the end of the last function call.
The variable should be modified in some way in the function (incremented for
instance) and it should have the modified value on subsequent calls. I have
one solution, but I think there could be others.
Here's one approach, which could be made better:
>> f: function [] [ls] [if none? ls [ls: [0]] ls/1: ls/1 + 1 print ls/1]
>> f
1
>> f
2
>> f
3
>> f
4
>> f
5
>> source f
f: func [/local ls][if none? ls [ls: [5]] ls/1: ls/1 + 1 print ls/1]
>> ls
** Script Error: ls has no value.
** Where: ls
> 2. Can you create a line of REBOL code, including two or more
functions of arity one or more (that take one or more parameters), that
results in the same result forwards or backwards?
My answer is: write a dataflow program in REBOL. Then the lines of code can
be shuffled or reversed with no change to the program.
Andrew Martin
Still thinking about the rest...
[EMAIL PROTECTED]
http://members.xoom.com/AndrewMartin/
-><-