> I hope someone else enjoys it too.

Well, it did get me to build a recent
Python.  Am I hopelessly old-fashioned
for thinking 6M a bit on the fat side
for a source distribution?

To play with it, I rewrote some code* I
had written in another rewrite language:

> sed -e ":s;s/xxx\(x*\)/xx\1gx\1/;ts;s/x[x]*/x/g;s/g//g"

The code is perhaps a bit less succinct
in your rewriter, but also much clearer.

-Dave

::::::

      r(1 s(0))
      r(2 s(1))
      r(3 s(2))
      r(4 s(3))
      r(5 s(4))
      r(6 s(5))
will rewrite 1 to s(0)
will rewrite 2 to s(1)
will rewrite 3 to s(2)
will rewrite 4 to s(3)
will rewrite 5 to s(4)
will rewrite 6 to s(5)
      r(p(0 $x) $x)
      r(p(s($x) $y) p($x s($y)))
will rewrite p(0 $x) to $x
will rewrite p(s($x) $y) to p($x s($y))
      r(f(s(s(s($x)))) p(f(s(s($x))) f(s($x))))
      r(f(s(s(0))) 1)
      r(f(s(0)) 1)
will rewrite f(s(s(s($x)))) to p(f(s(s($x))) f(s($x)))
will rewrite f(s(s(0))) to 1
will rewrite f(s(0)) to 1
      f(4)
-> s(s(s(0)))
      f(5)
-> s(s(s(s(s(0)))))
      f(6)
-> s(s(s(s(s(s(s(s(0))))))))

::::::

* sed script from a winter FoRKpost:
<http://www.xent.com/pipermail/fork/2002-January/008578.html>
I haven't made much progres with the ideas
in there, but I have noticed that although
sed is, for most purposes, more limiting
than awk, it can handle iterated rewriting
in distinct phases -- van Oortmerssen's
local rules seem to be a more structured
way of applying that kind of power.

Reply via email to