Guest User

Untitled

a guest
Sep 22nd, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 0.68 KB | None | 0 0
  1. {.checks: off, optimization: speed.}
  2.  
  3. from strutils import parseInt
  4. import tables, sequtils
  5.  
  6. type Vertex = ref object of RootObj
  7.   final: bool
  8.   id: int
  9.  
  10.  
  11. type Automaton = ref object of RootObj
  12.   edges: seq[Table[string, seq[int]]]
  13.   vertices: seq[ptr Vertex]
  14.   startingVertex: int
  15.  
  16.  
  17. proc divideString(g: var Automaton, key: string, val: var seq[int]) =
  18.   for i in 0..<len(key):
  19.     add(g.vertices, (alloc(Vertex(final = false, id = g.vertices.len))))
  20.  
  21.  
  22. proc relaxEdges(g: var Automaton) =
  23.   for id, v in g.vertices:
  24.     for key, val in g.edges[id]:
  25.       if len(key) > 1:
  26.  
  27.  
  28.  
  29. var g: Automaton = Automaton(vertices = @[0..3, ptr Vertex], starting_vertex = 0, size = 4)
Advertisement
Add Comment
Please, Sign In to add comment