Funny you should mention that. In the first few weeks of Clojure's
release, it was mentioned on the PLT list, where Shriram here:
http://list.cs.brown.edu/pipermail/plt-scheme/2007-November/021541.html
asked for an implementation of the core idea in the paper that
underlies the presentation to which you linked:
http://www.cs.brown.edu/~sk/Publications/Papers/Published/sk-automata-macros/paper.pdf
The core algorithm is this (in Scheme):
(define machine
(letrec ([init
(lambda (stream)
(cond
[(empty? stream) true]
[else
(case (first stream)
[(c) (more (rest stream))]
[else false])]))]
[more
(lambda (stream)
(cond
[(empty? stream) true]
[else
(case (first stream)
[(a) (more (rest stream))]
[(d) (more (rest stream))]
[(r) (end (rest stream))]
[else false])]))]
[end
(lambda (stream)
(cond
[(empty? stream) true]
[else
(case (first stream)
[else false])]))])
init))
to which I replied:
http://list.cs.brown.edu/pipermail/plt-scheme/2007-November/021623.html
Which in current Clojure would look like:
(defn machine [stream]
(let [step {[:init 'c] :more
[:more 'a] :more
[:more 'd] :more
[:more 'r] :end
[:end nil] :t}]
(loop [state :init
[f & r] stream]
(when-let next (step [state f])
(or (= next :t) (recur next r))))))
(machine '(c a d a d d r ))
-> true
(machine '(c a d a d d r r))
-> nil
Rich