From: Enoch <ix...@ho...> - 2013-02-16 17:47:31
|
Hi, Excuse me folks, while I am a (very) experienced embedded programmer Forth for me is a new experience. So here's another joy discovery. The old Forth sage tell us to use decision tables rather than case and nested if-s, so here's my "sling" for your review that I use in the implementation of a state machine: \ sling table generator, doc via example: \ : first ." first" ; \ : second ." second" ; \ : third ." third" ; \ ' third ' second ' first sling shot \ \ 1 shot → second ok \ -1 shot → ok : sling create ( i × xt -- ) depth , begin depth while , repeat does> ( n -- ? ) over over @i U< if 1+ + @i execute else 2drop then ; Cheers, Enoch. |