0. Excited to be in England
1. English country, I have accent.
2. Fear and guilt
3. Fear of plugs and outlets
4. Can't stop thinking of strange
5. Romance Ebi
Slide 11
Slide 11 text
Manchester
Agile
Rails
Slide 12
Slide 12 text
No content
Slide 13
Slide 13 text
No content
Slide 14
Slide 14 text
No content
Slide 15
Slide 15 text
No content
Slide 16
Slide 16 text
! WARNING !
Slide 17
Slide 17 text
Graphviz
http://graphviz.org
Slide 18
Slide 18 text
world
hello
greeting
Slide 19
Slide 19 text
digraph nfa {
rankdir=LR;
world [shape = doublecircle];
hello [shape = circle];
hello -> world [label="greeting"];
}
graph.dot
Slide 20
Slide 20 text
digraph nfa {
rankdir=LR;
world [shape = doublecircle];
hello [shape = circle];
goodbye [shape = circle];
hello -> world [label="greeting"];
goodbye -> world
}
graph.dot
/\/articles(?:.([^.\/?]+))?$/
/\/articles\/new(?:.([^.\/?]+))?$/
/\/articles\/([^.\/?]+)\/edit(?:.([^.\/?]+))?$/
/\/articles\/([^.\/?]+)(?:.([^.\/?]+))?$/
GET /articles/new
200 OK!
Slide 45
Slide 45 text
/\/articles(?:.([^.\/?]+))?$/
/\/articles\/new(?:.([^.\/?]+))?$/
/\/articles\/([^.\/?]+)\/edit(?:.([^.\/?]+))?$/
/\/articles\/([^.\/?]+)(?:.([^.\/?]+))?$/
GET /foos/new
404 Not Found
class Simulator
def initialize(dfa)
@dfa = dfa
end
def simulate(symbols)
state = 0
until symbols.empty?
state = @dfa.move(state, symbols.shift)
end
state
end
end
Slide 78
Slide 78 text
class DFA
...
def move(from, symbol)
@table[from][symbol]
end
end
move function
Slide 79
Slide 79 text
irb> sim = Simulator.new(DFA.new)
=> #
irb> sim.simulate %w{ b a a b b }
=> 3
irb> sim.simulate %w{ a a b }
=> 2
FSM Simulation
class Simulator
def initialize(nfa)
@nfa = nfa
end
def simulate(symbols)
states = @nfa.nil_closure([0])
until symbols.empty?
next_s = @nfa.move(states, symbols.shift)
states = @nfa.nil_closure(next_s)
end
states
end
end
Slide 91
Slide 91 text
Move function
class NFA
...
def move(states, symbol)
states.map { |s| @table[s][symbol] }.flatten
end
end
Slide 92
Slide 92 text
irb> sim = Simulator.new(NFA.new)
=> #
irb> sim.simulate %w{ a }
=> [6]
irb> sim.simulate %w{ b }
=> [6]
irb> sim.simulate %w{ b b }
=> []
irb> sim.simulate %w{ c }
=> []
Slide 93
Slide 93 text
Time: O(r ⨉ x)
r = operators.length, x = string.length