@@ -2,22 +2,29 @@ MiniLisp with REPL
22==================
33
44Foreword by N. Janin:
5- This is my attempt at making Rui Ueyama (rui314)'s MiniLisp slightly more user friendly and powerful.
6- Not being limited by the 1000 lines challenge, I've added a few basic primitives
5+ This is my attempt at making Rui Ueyama (rui314)'s MiniLisp slightly more user friendly
6+ and powerful.
7+ Not being limited by the 1000 lines challenge, I've added a number of basic primitives
78to the original program, while trying to keep the goal of simplicity and conciseness.
9+ The whole program compiles to less than 100 kb without debugging symbols and should be
10+ able to run on low powered devices.
11+
812The whole program compiles to less than 100 kb and should be able to run on low powered devices.
913The added primitives:
10- * operators >, >=, <=, or, and, not,
14+ * strings
15+ * predicates >, >=, <=, or, and, not,
1116* functions length, reverse, progn, load.
12- This has the side effect of being much faster as well, since all these primitives are compiled
13- instead of being interpreted.
17+
18+ This has the side effect of being much faster as well, since all these primitives are
19+ compiled instead of being interpreted.
1420
1521Among the bells and whistles, I've added a REPL based on Justine Tunney (jart)'s bestline.
1622
1723In this version, instead of passing a file using pipes, you simply pass the files as command parameters :
1824./minilisp f1 f2 etc
1925
20- The files all share the same environment, so all the symbols, functions and macros defined in f1 can be reused in the following files.
26+ The files all share the same environment, so all the symbols, functions and macros defined
27+ in f1 can be reused in the following files.
2128
2229## Shortcuts
2330
@@ -93,7 +100,6 @@ Known bugs:
93100
94101
95102Original README (completed)
96- >>>>>>> master
97103---------------
98104
99105One day I wanted to see what I can do with 1k lines of C and
181187 (setcar cell 'x)
182188 cell ; -> (x . b)
183189
184- ` length ` and ` reverse ` operate on a whole list or a on string.
185- They can also operate on their arguments when their number is > 1.
190+ ` length ` and ` reverse ` operate on a whole list or a string. They can also operate on their
191+ arguments when their number is > 1.
186192
187193 (length '(1 2 3)) ; -> 3
188194 (length 1 2 t) ; -> 3
@@ -222,7 +228,7 @@ the second.
222228 (< 3 3) ; -> ()
223229 (< 4 3) ; -> ()
224230
225- The other comparison operators ` > ` , ` <= ` , ` >= ` work in a similar fashion.
231+ The other numerical predicates ` > ` , ` <= ` , ` >= ` work in a similar fashion.
226232
227233` and ` takes two or more arguments, evaluates them, and returns the last argument
228234that returns true, if all the arguments return true, or () otherwise.
@@ -239,10 +245,10 @@ that returns true.
239245 (or () ()) ; -> ()
240246 (or) ; -> ()
241247
242- NB : because all the arguments are evaluated, ` and ` and ` or ` do not operate like
243- their counterparts written in Lisp, as those stop evaluation at the first argument
244- that returns. If the arguments have side effects, this may affect the program
245- differently.
248+ Nota Bene : because all the arguments are evaluated, ` and ` and ` or ` do not operate
249+ like their counterparts written in Lisp, as those stop evaluation at the first
250+ argument that returns. If the arguments have side effects, this may affect the
251+ program differently.
246252
247253### Conditionals
248254
@@ -262,12 +268,11 @@ exhaustion error.
262268
263269### Imperative programming
264270
265- ` progn ` executes several expressions consecutively .
271+ ` ( progn expr expr ...) ` executes several expressions in sequence .
266272
267- (progn (print 'I 'own)
268- (defun add(x y)(+ x y)
269- (println (add 3 7) 'cents))) ; -> I own
270- 10 cents
273+ (progn (print "I own ")
274+ (defun add(x y)(+ x y))
275+ (println (add 3 7) " cents")) ; -> prints "I own 10 cents"
271276
272277### Equivalence test operators
273278
@@ -284,7 +289,7 @@ contents but actually different are considered to not be the same by `eq`.
284289
285290` string-concat ` concatenates strings.
286291
287- (string-concat) ; -> ""
292+ (string-concat) ; -> ""
288293 (string-concat "A" "B" "C" "D") ; -> "ABCD"
289294
290295` symbol->string ` turns a symbol into a string.
@@ -300,8 +305,9 @@ contents but actually different are considered to not be the same by `eq`.
300305
301306` print ` prints a given object to the standard output.
302307
303- (print 3) ; prints "3"
304- (print '(hello world)) ; prints "(hello world)"
308+ (print 3) ; -> "3"
309+ (print '(hello world)) ; -> "(hello world)"
310+ (print "hello" "world") ; -> "hello world"
305311
306312` println ` does the same, adding a return at the end.
307313
@@ -371,9 +377,10 @@ is not defined.
371377### System functions
372378` load ` loads a Lisp file and evaluates all its content, adding it to the environment.
373379
374- (load 'example/nqueens.lisp) -> run the file and store its evaluated functions and macros
380+ (load "example/nqueens.lisp") -> run the file and store its evaluated functions
381+ and macros
375382
376- ` exit ` quits the interpreter and returns integer passed as parameter.
383+ ` exit ` quits the interpreter and returns the integer passed as parameter.
377384
378385 (exit 0) -> quit with success
379386
0 commit comments