-
Notifications
You must be signed in to change notification settings - Fork 3
A rewrite-rule language
License
darius/req
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
req - a programmable calculator using rewrite rules To build: make To run: cp reqrc ~/.reqrc; ./req Example runs: $ req 2+3 5 $ req > sphere_area(?r) == 4 * pi * ?r^2 ok > sphere_area(R_earth) / (1 mile)^2 # Earth's surface area in square miles 197060797.4 > Term rewriting goes beyond defining functions like sphere_area here: think of manipulating symbolic data in Mathematica (which is of course much fancier). This was my first substantial C program, written in the late 1980s. I do still use it as a calculator (it's handy with the physical constants and units), but I don't maintain or support it. Notable files: Notes The beginnings of a tutorial with some sample code test/ Directory with more sample code req.c Main program reqrc Sample .reqrc file bertrand/ Lame-o beginnings of an augmented term rewriter based on Wm Leler's book _Constraint Programming Languages_ -- I haven't looked at it in a long time and it probably doesn't work. Thanks to Steve Jenson for getting it to build on OS X. Darius Bacon <darius@wry.me> P.S. on the history: In school I took an unusual intro class on algorithms and data structures from Dave Gillespie, the author of GNU Calc. The assignments built on each other to develop a basic Mathematica-style symbolic math program, in Pascal. (Mathematica did not exist yet -- rather, Gillespie was influenced by Wolfram's first system, https://en.wikipedia.org/wiki/SMP_(computer_algebra_system).) It was a fun course -- I think any loss of core subject focus for the symbolic math stuff was outweighed by the interest and realism of the project. Project courses don't have to be limited to compilers and OSes. The next summer, I learned C by working through K&R and then rewriting this program in it. As a rewrite, it had some changes, but all I remember is that I left out a few features meant to support symbolic algebra in particular, leaving a more generic term-rewriting language. At this point, while thinking about and prototyping some more serious math support, I started feeling slowed down by C's low level, especially for debugging. Lisp turned out to answer much better, and that was the end of active development of req. The program was complete enough though to be useful to me for physical calculations, and occasionally handy for the symbolic manipulation stuff. It's nice to have a tool you understand completely. I think I posted this code to alt.sources in the 90s.
About
A rewrite-rule language
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published