This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
projects:minilisp [2006/04/04 20:03] leonb |
projects:minilisp [2016/02/17 09:56] (current) leonb [MiniLisp] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== MiniLisp ====== | ====== MiniLisp ====== | ||
- | So many years working with [[lush]] have taken their toll. | + | {{lambda.jpg? |
+ | Many years working with [[lush|Lush]] have taken their toll. | ||
There are many things I really dislike doing in C or C++ | There are many things I really dislike doing in C or C++ | ||
when I know how easy they would be in Lisp. | when I know how easy they would be in Lisp. | ||
+ | The essential lisp data structure is called the S-Expression. | ||
+ | S-Expressions can represent lots of complicated things | ||
+ | using a simple printable format. | ||
+ | reason why many people find XML or JSON appealing. | ||
+ | But I keep returning to S-Expression because they are so much simpler. | ||
Line 18: | Line 23: | ||
MiniExp handles four basic types of S-expressions: | MiniExp handles four basic types of S-expressions: | ||
- | * Integers, in range < | + | * Integers, in range [-2<sup>29</ |
* Symbols, which are small strings represented by a unique handle. | * Symbols, which are small strings represented by a unique handle. | ||
* Pairs, which are the basic components of lists. | * Pairs, which are the basic components of lists. | ||
Line 59: | Line 64: | ||
===== MiniLisp ===== | ===== MiniLisp ===== | ||
- | FIXME | + | During the development of '' |
+ | appeared that the best way to test s-expressions was to make | ||
+ | the last step and program a complete lisp interpreter. | ||
+ | Let's see what it can do: | ||
+ | |||
+ | MiniLisp, (C) 2005, Leon Bottou. | ||
+ | Available under the GNU General Public Licence. | ||
+ | (+ 2 3) | ||
+ | = 5 | ||
+ | | ||
+ | = square | ||
+ | | ||
+ | = 25 | ||
+ | | ||
+ | = sum | ||
+ | (sum '(1 8 7 3)) | ||
+ | = 19 | ||
+ | | ||
+ | (defun (sum l) (if (consp l) (+ (car l) (sum (cdr l))) 0)) | ||
+ | = () | ||
+ | | ||
+ | (defmacro (pretty f) | ||
+ | (let ((s (if (symbolp f) (list (list quote f))))) | ||
+ | (list (quote let) | ||
+ | (list (list (quote s) (list (quote funcdef) f . s))) | ||
+ | (list (quote pprint) (quote s) 72) | ||
+ | () ) ) ) | ||
+ | = () | ||
+ | |||
+ | |||
+ | The interpreter is very slow because symbol lookup is not optimized. | ||
+ | But it makes a nice example of using MiniExp. | ||
===== Download ===== | ===== Download ===== | ||
- | Both MiniExp | + | The most recent |
+ | |||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | |||
+ | The documentation is in file '' | ||
+ | You can also check the MiniLisp source: | ||
- | * [[http://cvs.sourceforge.net/ | + | * [[http:// |
- | * [[http:// | + | |
- | * [[http:// | + | |
- | But it might be simpler to download the tarball here: {{minilisp-1.0.tar.gz}} |