Skip to content

hagabaka/finite-automaton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a library for describing and using finite automata in Ruby.

Defining

m = FiniteAutomaton.new('a')
m.add_transition('a', 1, 'b')
m.add_transition('b', 0, 'a')
m.add_transition('a', 0, 'a')
m.add_transition('b', 1, 'b')
m.accept_states << 'b'

Or use the DSL

Using

m.deterministic? #=> true
m.accept? [0, 1, 0] #=> false
m.accept? [1, 1, 0, 0, 0, 1] #=> true

Visualizing

require 'open3'
Open3.popen3('graph-easy') do |i,o,_|
  i << m.to_graph_easy
  i.close
  puts o.read
end
               0
       +--------------+
       v              |
     +-------+  1   #=======#
 --> |   a   | ---> H   b   H
     +-------+      #=======#
       ^ 0 |          ^ 1 |
       +---+          +---+

Access

Rdoc
hagabaka.github.com/finite-automaton
GitHub
github.com/hagabaka/finite-automaton/tree/master

About

A Ruby library for describing and using Finite Automata

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages