Close
Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

LABS
Term rewriting. It looks to be powerful!

This weekend I discovered the Q language. Check this out: Into a file called sq.q I type:

sq X = X * X;
X+(Y+Z) = (X+Y)+Z; X*(Y*Z) = (X*Y)*Z;
X*(Y+Z) = X*Y+X*Z; (X+Y)*Z = X*Z+Y*Z;

This is the definition of square, followed by the laws for distributivity and associativity as they could be copied directly out of a textbook. Then I evaluate this file in the Q VM-based interpreter, whose speed apparently rivals that of the Glasgow Haskell Compiler or CLISP:

q sq.q

In the interepretter window I then type a term, and using my rules Q reduces it to normal form:

==> sq (A+B)
A*A+B*A+A*B+B*B

I am pretty sure this language is going to unleash an unreal amount of metaprogramming power. Term rewriting is a genius idea.

Comments
Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *