I felt inspired by the "Polymorphic IF" and the "non-deterministic REBOL"
threads, so I decided to whip up a state machine in REBOL. Here it is:
Machine: make object! [
_State: word!
State: func [][_State]
Goto: func ['Next [word!]][
_State: Next
]
Start: func ['Initial [word!]][
_State: Initial
]
Run: func [][
while [_State][
try [do State true]
]
]
Stop: func [][
_State: false
]
Stop
]
na: 0
nb: 0
a: func [] [
na: na + 1 print ["na:" na] Machine/Goto b
]
b: func [] [
nb: nb + 1 print ["nb:" nb]
either nb < 10 [
Machine/Goto a
][
Machine/Stop
]
]
Machine/Start a
Enjoy!
Andrew Martin
Waiting for REBOL/View...
ICQ: 26227169
[EMAIL PROTECTED]
http://members.xoom.com/AndrewMartin/
-><-
- [REBOL] Printing decimal values Re: KGD03011
- [REBOL] Printing decimal values Re:(2) joel . neely
- [REBOL] Printing decimal values Re:(2) lmecir
- [REBOL] Printing decimal values Re: KGD03011
- [REBOL] State Machine Re: Al . Bri
- [REBOL] State Machine Re: Al . Bri
- [REBOL] State Machine Re:(2) icimjs
- [REBOL] State Machine Re:(3) Al . Bri
- [REBOL] State Machine Re:(3) Al . Bri
- [REBOL] For lmecir
- [REBOL] Polymorphic lmecir
- [REBOL] Polymorphic Re: robert . muench
- [REBOL] Polymorphic Re:(2) Al . Bri
- [REBOL] Re: Polymorphic giesse
- [REBOL] Polymorphic Re:(2) lmecir
