Hey! This IS fun! I can get all kinds of strange results by tweeking the
block logic.

Among the several versions of incorrect results, I have found how to
achieve the expected results (I must bypass using 'append):

>> a: [insert tail a [+ 1] 1]
== [insert tail a [+ 1] 1]
>> print compose a
1
>> print compose a
2
>> print compose a
3

Using two 'inserts yeilds a different animal, however. Note the block
structure that 'reduce displays:

>> a: [insert tail a '+ insert tail a 1 1]
== [insert tail a '+ insert tail a 1 1]
>> print compose a
1  1
>> print compose a
1  2
>> print compose a
1  3
>> reduce compose a
== [[1] [] 4]

- Michael Jelinek





[EMAIL PROTECTED] on 10/10/2000 07:09:04 AM

From: [EMAIL PROTECTED] on 10/10/2000 07:09 AM

Please respond to [EMAIL PROTECTED]
To:   [EMAIL PROTECTED]
cc:
Subject:  [REBOL] Fun with blocks and ops.


Here some fun with a self-modifying block :)

>> a: [append a [+ 1] 1]
== [append a [+ 1] 1]
>> do a
== 1
>> do a
== 2
>> do a
== 3
>> do a
== 4
>> do a
== 5
>> do a
== 6             <---- !
>> do a
== 8             <---- !
>> do a
== 9

And even more fun is:

>> a: [append a '+ append a 1 1]
== [append a '+ append a 1 1]
>> do a
== 1
>> do a
== 2
>> do a
== 3
>> do a
== 4
>> do a
== 5
>> do a
== 7       <-----
>> do a
== 8

[ ..... ]

>> do a
== 12
>> do a
** Script Error: Operator is missing an argument.
** Where: 1 + 1 + 1
>> do a
== 13
>> do a
== 15   <-------
>> do a
== 16
>> do a
== 17

[ .... ]

>> do a
== 28
>> do a
** Script Error: Operator is missing an argument.
** Where: 1 + 1 + 1
>> do a
== 29
>> do a
== 31










Reply via email to