I wanted to visualise this with the graphviz addon
(http://code.jsoftware.com/wiki/Addons/graphics/graphviz), but that
seems
to have disappeared, i.e. its not in the package manager. Anyone know
what happened to it?
In any case, this answer helped me learn J's FSM. thanks!
Ryan
On 9 Dec 2015, at 2:23, David Lambert wrote:
Part 1, a chance to exercise the FSM. The states here are sufficient
for character count. Raul's annotated state table style is worth
reiterating, hence this post. Fixed width font aligns the columns.
mp=: +/ .*
S=: +. ". }. [;._2 noun define
bore hex \ " x LF
0j6 0j6 0j6 6j0 0j6 0j0 NB. 0 between strings j=_1
2j1 2j1 3j0 1j3 2j1 0j0 NB. 1 terminating "
2j0 2j0 3j3 1j3 2j0 0j6 NB. 2 amid string
0j6 0j6 2j1 2j1 4j0 0j6 NB. 3 allow \"x after leading \
0j6 5j0 2j1 2j1 5j0 0j6 NB. 4 first hex digit
0j6 2j1 0j6 0j6 0j6 0j6 NB. 5 second hex digit
2j1 2j1 3j0 1j0 2j1 0j6 NB. 6 first char of string
)
M=: a.(>:@i.@#@] mp (e.>)"1 0)'0123456789abcdef';;/'\"x',LF
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm