Pdfsm is a deterministic finite state machine with signal input (written by by ccos).
a list consisting of the stream which gives input signals to determine state transitions, and then dictionary entries, one for each state, mapping the destination state and yield streams to those input signals.
an integer index for the state to start with.
an integer giving the number of times the pattern should cycle. A cycle ends when the signal stream ends or nil is given for the destination state to a signal value, see below.
If the fsm is in state x and it receives a signal value y it looks up y in the state dictionary supplied for x, if there is no y entry, it looks for a \default entry and uses that.
The next state is then set to destination state, and the stream yielded is given by return stream or pattern. That is unless the destination state is given as nil, or if a destination state is given for which you have not supplied a dictionary - in both cases the current cycle ends and any remaining repeats are executed. If there is no signal value given for a particular signal, and no \default is supplied then one will get a runtime error.