Automaton

Nov. 8, 2013, 2:57 p.m.
function Automaton(substr) {
    this.delta = [{"a":0, "b":1}, {"a":1, "b":0}];
    this.state = 0;
    this.search = function(str) {
        this.state = 0;
        for (var i = 0; i < str.length; i++) {
            this.state = this.delta[this.state][str.charAt(i)];
            WSH.Echo(this.state);
        }
    }
}

var a = new Automaton("...");
a.search("ababbbba");
comments powered by Disqus