diff --git a/doc/DRAWL.md b/doc/DRAWL.md index 0b02850..dda4b0b 100644 --- a/doc/DRAWL.md +++ b/doc/DRAWL.md @@ -26,6 +26,7 @@ However, the code is partitioned to allow for easy extension so some of these mi - LoRes Apple II graphics - Ctrl-C break into running program - MACROs for meta-programming. See [defun.lisp](https://github.com/dschmenk/PLASMA/blob/master/src/lisp/defun.lisp) +- End-of-line comment using ';' The DRAWL implementation comes with the following built-in functions: diff --git a/images/apple/DRAWL.po b/images/apple/DRAWL.po index 11e9c78..2db7459 100644 Binary files a/images/apple/DRAWL.po and b/images/apple/DRAWL.po differ diff --git a/src/lisp/defun.lisp b/src/lisp/defun.lisp index 75a603f..cc4fab8 100644 --- a/src/lisp/defun.lisp +++ b/src/lisp/defun.lisp @@ -1,3 +1,6 @@ +; +; USE MACRO TO SIMPLIFY FUNCTION DEFINITION +; (DEFINE (DEFUN (MACRO (L) (EVAL (CONS 'DEFINE (LIST (CONS (CAR L) (LIST (CONS 'LAMBDA (CDR L))))))) diff --git a/src/lisp/fact.lisp b/src/lisp/fact.lisp index 2e206f3..a955cec 100644 --- a/src/lisp/fact.lisp +++ b/src/lisp/fact.lisp @@ -1,3 +1,6 @@ +; +; Recursive factorial +; (define (fact (lambda (n) (cond ((eq n 0) , 1) diff --git a/src/lisp/gcd.lisp b/src/lisp/gcd.lisp index 39eb1a6..a084f95 100644 --- a/src/lisp/gcd.lisp +++ b/src/lisp/gcd.lisp @@ -1,4 +1,7 @@ -((label +; +; Example from LISP 1.5 manual using LABEL instead of DEFINE +; +((label gcd (lambda (x y) (cond ((> x y) , (gcd y x)) ((eq (rem y x) 0) , x) diff --git a/src/lisp/list.lisp b/src/lisp/list.lisp index c41ae23..8e5a9b0 100644 --- a/src/lisp/list.lisp +++ b/src/lisp/list.lisp @@ -1,3 +1,6 @@ +; +; Example from LISP 1.5 manual +; (define (equal (lambda (x y) (cond ((and (atom x) (atom y)) (eq x y)) diff --git a/src/lisp/loop.lisp b/src/lisp/loop.lisp index b4025ce..d4aed29 100644 --- a/src/lisp/loop.lisp +++ b/src/lisp/loop.lisp @@ -1,8 +1,14 @@ (DEFINE + ; + ; TAIL LOOP RECURSION + ; (TAILLOOP (LAMBDA (I M) (COND ((AND (< I M) (PRIN I)),(TAILLOOP (+ 1 I) M)) (T,(- I 1))) )) + ; + ; ITERATE INSIDE PROG() + ; (PROGLOOP (LAMBDA (I M) (PROG () A (PRIN I) @@ -10,6 +16,9 @@ (IF (< I M) (GO A)) (RETURN (- I 1)) ))) + ; + ; FOR LOOP EXTENSION + ; (FORLOOP (LAMBDA (I M) (FOR I I 1 (< I M) (PRIN I)) )) diff --git a/src/lisp/lores.lisp b/src/lisp/lores.lisp index 69fbb8a..5b02d62 100644 --- a/src/lisp/lores.lisp +++ b/src/lisp/lores.lisp @@ -1,3 +1,6 @@ +; +; LORES GRAPHICS TRIG PLOTTING EXAMPLE +; (DEFINE (PLOTFUNC (LAMBDA (FN) (PROG (I X Y) @@ -10,9 +13,17 @@ (RETURN 0) ) )) + ; + ; USE FUNCTION TO PASS IN LAMBDA EQUATIONS + ; BEST OPTION FOR GENERIC CASE + ; (PLOTSIN (LAMBDA () (PLOTFUNC (FUNCTION (LAMBDA (S) (SIN (* S PI))))) )) + ; + ; USE QUOTE TO PASS IN LAMBDA EQUATION + ; ONLY APPLICABLE IF NO FREE VARIABLES + ; (PLOTCOS (LAMBDA () (PLOTFUNC '(LAMBDA (S) (COS (* S PI)))) )) @@ -22,3 +33,5 @@ (PLOTSIN) (COLOR 9) (PLOTCOS) +; RETURN TO TEXT MODE - UNCOMMENT NEXT LINE +; (GR F) diff --git a/src/lisp/maplist.lisp b/src/lisp/maplist.lisp index dfecc4e..357081b 100644 --- a/src/lisp/maplist.lisp +++ b/src/lisp/maplist.lisp @@ -1,3 +1,6 @@ +; +; Sample from LISP 1.5 Manual +; (define (ydot (lambda (x y) diff --git a/src/lisp/minmax.lisp b/src/lisp/minmax.lisp index 1391741..7975105 100644 --- a/src/lisp/minmax.lisp +++ b/src/lisp/minmax.lisp @@ -1,3 +1,6 @@ +; +; ALTERNATIVE MIN/MAX USING LIST ARGUMENT +; (DEFINE (MINL (LAMBDA (M L) (COND ((NULL L), M) diff --git a/src/lisp/prog.lisp b/src/lisp/prog.lisp index c00f698..0146add 100644 --- a/src/lisp/prog.lisp +++ b/src/lisp/prog.lisp @@ -1,5 +1,8 @@ (define (lengthc (lambda (l) + ; + ; Use cond() inside prog() + ; (prog (u v) (setq v 0) (setq u l) @@ -10,6 +13,9 @@ ) )) (lengthi (lambda (l) + ; + ; Use if/then/else inside prog() + ; (prog (u v) (setq v 0) (setq u l) diff --git a/src/lisp/s-expr.pla b/src/lisp/s-expr.pla index db4725b..a640bd7 100644 --- a/src/lisp/s-expr.pla +++ b/src/lisp/s-expr.pla @@ -559,6 +559,7 @@ export def parse_expr(evalptr, level, refill)#2 // return evalptr, exprptr elemptr = NULL when ^evalptr is 0 + is ';' // Comment to end of line if level evalptr = refill() // Refill input buffer else diff --git a/src/lisp/set.lisp b/src/lisp/set.lisp index f36c1e8..2ea9bff 100644 --- a/src/lisp/set.lisp +++ b/src/lisp/set.lisp @@ -1,3 +1,6 @@ +; +; Example from LISP 1.5 manual +; (define (member (lambda (a x) (cond ((null x) , f)