IU-Match
PLT Scheme has a match command, but it's syntax is different from that
used by Chez Scheme's match command. I won't go into the differences
here, but suffice it to say, it would be a pain to convert (by hand) PLT
match expressions back to Chez match expressions for assignments. (Of
course, it would be trivial to write a Scheme program to do
that, probably in under 20 lines too. But I'm lazy, in a good way (link
forthcoming on the virtues of programming laziness..)
Matt Jadud, a former
graduate student at IU, now working over in England at Kent, wrote a module
for PLT Scheme that includes code to make IU's match command work with
DrScheme. Matt says thanks to
Matthew
Flatt for his work on the IU match port. If you really want to see
the PLT module file for this, it is here
along with some other stuff Matt wrote including that big hariy monster
that anyone in IUCS has had a run-in with called VINCENT!!!
Anyway, Matt has put together a this package for PLT Scheme whose
real purpose is to parse XML code in Scheme. But as a side benefit, it
includes a PLT-compatible version of the IU matcher. Here are the
instructions:
Two files are needed:
This solution is known to work with the latest version of the PLT
Scheme package (version 2.06p1) as well as the earlier version 2.0.5.
The Language must be set to (at least) 'Textual' under the PLT tab, and
not just the Standard (R5RS). The Standard language doesn't define the
require procedure, which is needed to use the PLT module system. To set
the language, select "Choose Language" under the "Language" menu, click
on the line PLT if the PLT lanauges are not shown, click on "Textual
(MzScheme, includes R5RS)", and click OK. You don't need to restart the
program.
Place these two files inside the /collects/mzlib directory, which is
inside the main PLT folder
The only thing that is needed to use the IU-syntax match command is the
following line at the top of the program:
(require (lib "iu-match.ss"))
Here is an exmaple program using the new
match command:
(require (lib "iu-match.ss"))
(define computer
(lambda (ls)
(match ls
[(,a) a]
[(,a + ,b) (+ (computer (list a)) (computer (list b)))]
[(,a - ,b) (- (computer (list a)) (computer (list b)))]
[(,a * ,b) (* (computer (list a)) (computer (list b)))]
[(,a / ,b) (/ (computer (list a)) (computer (list b)))])))
(computer '(1))
(computer '(3 + 5))
(computer '(9 * 3))
Dan Friedman's "Poor Man's" Logic System for Scheme with first-class
relations
This is a really neat (and really dense) logic-programming environment for
Scheme with first-class relations and transparent integration with normal
Scheme functions and predicates. More information can be found in his
76-page monster on this here in
PostScript format or here in a PDF
version for those who don't have GhostScript installed.
Anyway, while written in RSR5 scheme, is written for the Chez Scheme
enviornment primarily, and so has a two or three bits that are
incompatible with the PLT MzScheme implementation of RSR5. The following
files are modified to work with DrScheme:
- The verbosely-named pl.ss which is the full logic
library. There are also a few debugging macros that are described
below.
- A similar exercise in verbiage, plnew.ss
Which contains only a (relatively) small subset of the code in pl.ss,
which is used in the beginning of the C311 exploration of logic
programming to investigate how to use the system to define relations,
solve systems of logic equations, and deduce family relations from a
geneological database. This file only contains the macro
definitions function code, and no tests. Hence it is wiell suited for
inclusion into other files with
(load "plnew.ss")
- plnewtests.ss, which is a set of tests for
the "stipped-down" libarry in plnew.ss. These tests are taken directly from
the original pl.ss source.
The debugging functions (syntax definitions actually) are dbgfam, dbg, and
dbgt, and bracket all "test code" calls, and rely on the following three
debugging flags, defined at the beginning of pl.ss:
_dbf
If this is flag is true, then the test code for the
family tree example relations will execute. (Ignore what is says in the
file about this being a general flag..)
_db
This is the general debugging flag. This
control the execution of all examples except those controlled by the last
flag, or those controlled by following flag (aren't forward-declaration
constructions in English wonderful ;-) ?
_dbt
This flag concerns the code for the type-inference
examples that are present.
This code (as is D. Friedman's original) is in a constant state of flux..
Check back later, and check back often..
Enjoy yourself, and don't "bend-you-mind" too much..
Oh, and my the way, if you happen to find the zebra.. Throw it in a lake
for me, will you!