1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2024-12-29 01:30:22 +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
- 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:

Binary file not shown.

View File

@ -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)))))))

View File

@ -1,3 +1,6 @@
;
; Recursive factorial
;
(define
(fact (lambda (n)
(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)
(cond ((> x y) , (gcd y x))
((eq (rem y x) 0) , x)

View File

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

View File

@ -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))
))

View File

@ -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)

View File

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

View File

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

View File

@ -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)

View File

@ -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

View File

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