1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-01-01 06:32:07 +00:00

Add comments with ';'

This commit is contained in:
David Schmenk 2024-08-01 10:13:06 -07:00
parent 9f0289b5d6
commit 2c814d8829
13 changed files with 52 additions and 1 deletions

View File

@ -26,6 +26,7 @@ However, the code is partitioned to allow for easy extension so some of these mi
- LoRes Apple II graphics - LoRes Apple II graphics
- Ctrl-C break into running program - Ctrl-C break into running program
- MACROs for meta-programming. See [defun.lisp](https://github.com/dschmenk/PLASMA/blob/master/src/lisp/defun.lisp) - 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: The DRAWL implementation comes with the following built-in functions:

Binary file not shown.

View File

@ -1,3 +1,6 @@
;
; USE MACRO TO SIMPLIFY FUNCTION DEFINITION
;
(DEFINE (DEFUN (MACRO (L) (DEFINE (DEFUN (MACRO (L)
(EVAL (CONS 'DEFINE (EVAL (CONS 'DEFINE
(LIST (CONS (CAR L) (LIST (CONS 'LAMBDA (CDR L))))))) (LIST (CONS (CAR L) (LIST (CONS 'LAMBDA (CDR L)))))))

View File

@ -1,3 +1,6 @@
;
; Recursive factorial
;
(define (define
(fact (lambda (n) (fact (lambda (n)
(cond ((eq n 0) , 1) (cond ((eq n 0) , 1)

View File

@ -1,4 +1,7 @@
((label ;
; Example from LISP 1.5 manual using LABEL instead of DEFINE
;
((label
gcd (lambda (x y) gcd (lambda (x y)
(cond ((> x y) , (gcd y x)) (cond ((> x y) , (gcd y x))
((eq (rem y x) 0) , x) ((eq (rem y x) 0) , x)

View File

@ -1,3 +1,6 @@
;
; Example from LISP 1.5 manual
;
(define (define
(equal (lambda (x y) (equal (lambda (x y)
(cond ((and (atom x) (atom y)) (eq x y)) (cond ((and (atom x) (atom y)) (eq x y))

View File

@ -1,8 +1,14 @@
(DEFINE (DEFINE
;
; TAIL LOOP RECURSION
;
(TAILLOOP (LAMBDA (I M) (TAILLOOP (LAMBDA (I M)
(COND ((AND (< I M) (PRIN I)),(TAILLOOP (+ 1 I) M)) (COND ((AND (< I M) (PRIN I)),(TAILLOOP (+ 1 I) M))
(T,(- I 1))) (T,(- I 1)))
)) ))
;
; ITERATE INSIDE PROG()
;
(PROGLOOP (LAMBDA (I M) (PROGLOOP (LAMBDA (I M)
(PROG () (PROG ()
A (PRIN I) A (PRIN I)
@ -10,6 +16,9 @@
(IF (< I M) (GO A)) (IF (< I M) (GO A))
(RETURN (- I 1)) (RETURN (- I 1))
))) )))
;
; FOR LOOP EXTENSION
;
(FORLOOP (LAMBDA (I M) (FORLOOP (LAMBDA (I M)
(FOR I I 1 (< I M) (PRIN I)) (FOR I I 1 (< I M) (PRIN I))
)) ))

View File

@ -1,3 +1,6 @@
;
; LORES GRAPHICS TRIG PLOTTING EXAMPLE
;
(DEFINE (DEFINE
(PLOTFUNC (LAMBDA (FN) (PLOTFUNC (LAMBDA (FN)
(PROG (I X Y) (PROG (I X Y)
@ -10,9 +13,17 @@
(RETURN 0) (RETURN 0)
) )
)) ))
;
; USE FUNCTION TO PASS IN LAMBDA EQUATIONS
; BEST OPTION FOR GENERIC CASE
;
(PLOTSIN (LAMBDA () (PLOTSIN (LAMBDA ()
(PLOTFUNC (FUNCTION (LAMBDA (S) (SIN (* S PI))))) (PLOTFUNC (FUNCTION (LAMBDA (S) (SIN (* S PI)))))
)) ))
;
; USE QUOTE TO PASS IN LAMBDA EQUATION
; ONLY APPLICABLE IF NO FREE VARIABLES
;
(PLOTCOS (LAMBDA () (PLOTCOS (LAMBDA ()
(PLOTFUNC '(LAMBDA (S) (COS (* S PI)))) (PLOTFUNC '(LAMBDA (S) (COS (* S PI))))
)) ))
@ -22,3 +33,5 @@
(PLOTSIN) (PLOTSIN)
(COLOR 9) (COLOR 9)
(PLOTCOS) (PLOTCOS)
; RETURN TO TEXT MODE - UNCOMMENT NEXT LINE
; (GR F)

View File

@ -1,3 +1,6 @@
;
; Sample from LISP 1.5 Manual
;
(define (define
(ydot (ydot
(lambda (x y) (lambda (x y)

View File

@ -1,3 +1,6 @@
;
; ALTERNATIVE MIN/MAX USING LIST ARGUMENT
;
(DEFINE (DEFINE
(MINL (LAMBDA (M L) (MINL (LAMBDA (M L)
(COND ((NULL L), M) (COND ((NULL L), M)

View File

@ -1,5 +1,8 @@
(define (define
(lengthc (lambda (l) (lengthc (lambda (l)
;
; Use cond() inside prog()
;
(prog (u v) (prog (u v)
(setq v 0) (setq v 0)
(setq u l) (setq u l)
@ -10,6 +13,9 @@
) )
)) ))
(lengthi (lambda (l) (lengthi (lambda (l)
;
; Use if/then/else inside prog()
;
(prog (u v) (prog (u v)
(setq v 0) (setq v 0)
(setq u l) (setq u l)

View File

@ -559,6 +559,7 @@ export def parse_expr(evalptr, level, refill)#2 // return evalptr, exprptr
elemptr = NULL elemptr = NULL
when ^evalptr when ^evalptr
is 0 is 0
is ';' // Comment to end of line
if level if level
evalptr = refill() // Refill input buffer evalptr = refill() // Refill input buffer
else else

View File

@ -1,3 +1,6 @@
;
; Example from LISP 1.5 manual
;
(define (define
(member (lambda (a x) (member (lambda (a x)
(cond ((null x) , f) (cond ((null x) , f)