Hi - can someone more experienced with Arc help me debug this? I'm trying to write a finite state machine utility based on this paper: http://cs.brown.edu/~sk/Publications/Papers/Published/sk-automata-macros/paper.pdf But whenever I load my code into the repl I get an error: Error: "Can't take cdr of _"
The code: (def mktransition (tn) (list (car tn) (list (last tn) '(cdr str))))
(def mktransitions (ts)
(accum accfn
(each x (map1 mktransition ts)
(accfn (car x))
(accfn (last x)))))
(mac mkrule (r)
(let i r
`(list (car ,i) (fn (str)
(if (empty str) t
(case (car str)
,@(mktransitions (cdr i))))))))
(mac automaton (i r) `(withr/p ,(map1 [mkrule _] r) ,i))
Every time I dive in to fix this I come up feeling I'm evaluating r at the wrong time - but I can't seem to pin down how to fix it.Anyone have any ideas? |