Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {.checks: off, optimization: speed.}
- from strutils import parseInt
- import tables, sequtils
- type Vertex = ref object of RootObj
- final: bool
- id: int
- type Automaton = ref object of RootObj
- edges: seq[Table[string, seq[int]]]
- vertices: seq[ptr Vertex]
- startingVertex: int
- proc divideString(g: var Automaton, key: string, val: var seq[int]) =
- for i in 0..<len(key):
- add(g.vertices, (alloc(Vertex(final = false, id = g.vertices.len))))
- proc relaxEdges(g: var Automaton) =
- for id, v in g.vertices:
- for key, val in g.edges[id]:
- if len(key) > 1:
- var g: Automaton = Automaton(vertices = @[0..3, ptr Vertex], starting_vertex = 0, size = 4)
Advertisement
Add Comment
Please, Sign In to add comment