 
   formatTest: (val) ->
     if typeof(val) == "function"
-      "<function>"
+      "<lambda>"
     else if val == true
       return "<epsilon>"
     else


step = (current, val) ->
  next = {size: 0}
  for own id, thing of current when id != "size"
    state = thing[0]
    state.arcs.forEach (arc) ->
      if arc.test(val)
        leaf = new TreeNode(thing[1], val)
        if arc.nextState.final
          leaf.final = true
        else
          null
        next[arc.nextState.id] = [arc.nextState, leaf]
        next.size++
  next


    @finals[state.id] = state

  finalStates: ->
    state for own id, state of finals

  test: (sequence) ->
    state = @start
    current = {}
    next = {}
    tree = new TreeNode()
    current[state.id] = {state: state, tree: tree}
    for i in [0..sequence.length]
      val = sequence[i]
      next = step(current, val)
      if next.size == 0
        return testMatch(current, val)
      else if i == sequence.length - 1
        return testMatch(next, val)
