To give you the essential feeling, we provide the following example:
(defun isomorphic (tree1 tree2) (cond ((atom tree1) (atom tree2)) ((atom tree2) NIL) (t (and (isomorphic (car tree1) (car tree2)) (isomorphic (cdr tree1) (cdr tree2)) ))))
(L|DEFUN, ISOMORPHIC, (L|TREE1, TREE2), (L|COND, (L|(L|ATOM, TREE1), (L|ATOM, TREE2)), (L|(L|ATOM, TREE2), NIL), (L|T, (L|AND, (L|ISOMORPHIC, (L|CAR, TREE1), (L|CAR, TREE2)), (L|ISOMORPHIC, (L|CDR, TREE1), (L|CDR, TREE2)) ))))
// File isomorph.cpp #include "lisp/lisp.hpp" #include "lisp/lsymbol.hpp" #include "lfun_std.hpp" LSymbol ISOMORPHIC("ISOMORPHIC"); static LFunctionalSymbol<LFunctionDefun> DEFUN("DEFUN"); static LFunctionalSymbol<LFunctionCond> COND("COND"); static LFunctionalSymbol<LFunctionAtom> ATOM("ATOM"); static LFunctionalSymbol<LFunctionAnd> AND("AND"); static LFunctionalSymbol<LFunctionCar> CAR("CAR"); static LFunctionalSymbol<LFunctionCdr> CDR("CDR"); LListConstructor L; void LispInit_isomorphic() { static LSymbol TREE1("TREE1"); static LSymbol TREE2("TREE2"); // (L|DEFUN, ISOMORPHIC, (L|TREE1, TREE2), (L|COND, (L|(L|ATOM, TREE1), (L|ATOM, TREE2)), (L|(L|ATOM, TREE2), NIL), (L|T, (L|AND, (L|ISOMORPHIC, (L|CAR, TREE1), (L|CAR, TREE2)), (L|ISOMORPHIC, (L|CDR, TREE1), (L|CDR, TREE2)) )))).Evaluate(); // } // end of file
This is how the things look if you write in C++ "just like in Lisp". You can also write a whole module in the traditional Lisp syntax and then translate it into a C++ module if you want so.
sexpress
and the tools
directories.
The second layer, consisting of the genlisp
, lisp
and scheme
directories, implements the evaluation models of Lisp and Scheme.
Besides that, there are interactive interpreters for both InteLib Lisp and InteLib Scheme (they are named nill
and nils
). It is also possible to translate your Lisp/Scheme code into a C++ module which will use the InteLib conventions. This is done by translators named ill
and ils
, for Lisp and Scheme, respectively.
make library
build
directory.
It is not a bad idea to compile the interpreters and bootstrap the translators. Issue the make
command in the InteLib tree root to do so. Should you have no Gnu Readline, this step will fail, but you can force it to go without Readline issuing
make USE_READLINE=no
If you've got root privileges, you might want to install the library and the accompanying software on a system-wide basis. Try
make install