Skip to content

Generalize newStates #18

@mroman42

Description

@mroman42

newStates is an auxiliary function for listStates. Its type may be generalizable to:

(Automata a) => a -> State -> [State]

But to generalize its type, we would need to create a function whose particular cases for [] and Maybe were catMaybes and concat, as we can see here (from ToGraph.hs):

listStates :: DFA -> [State]
listStates dfa = stabilize (nub . concat . (map (newStates dfa))) [fromJust (initialDFA dfa)]

newStates :: DFA -> State -> [State]
newStates dfa s = s : catMaybes [(deltaDFA dfa) s a | a <- (alphaDFA dfa)]

listStatesNfa :: NFA -> [State]
listStatesNfa nfa = stabilize (nub . concat . (map (newStatesNfa nfa))) (initialNFA nfa)

newStatesNfa :: NFA -> State -> [State]
newStatesNfa nfa s = s : concat [(deltaNFA nfa) s a | a <- (alphaNFA nfa)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions