I don’t see how to define the classes which describes an application I’m trying to write. Can someone give me some suggestions? I mainly don’t see how it can be done functionally.
I have three kinds of entity. An Dfa
(deterministic finite automata) has a set of State
objects, along with two subsets, I
and F
of that set which denote the set, of initial states and the set of final states. A State
has a set of Transition
instances. A Transition
has a source State
and destination State
and a transition label which is an instance of some independent type, controlled by a type parameter.
One strategy would have the Dfa
constructor take a list of integers which name the states, a list of integers which designates the I subset, a list of Integers which designates the F subset, a list of 3-tuples containing integers representing the sources/destinations/labels, then allocate State instances and Transition Instances, and then using mutable manipulation to set the fields in the Transition instances pointing to the State objects, then using mutable manipulation set the fields of the State instances pointing to the Transition instances. Finally, set the fields of the Dfa
to the list of State instances and Transition instances?
That sounds awful.
Is there a better way?