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:
parent
9f0289b5d6
commit
2c814d8829
@ -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.
@ -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)))))))
|
||||
|
@ -1,3 +1,6 @@
|
||||
;
|
||||
; Recursive factorial
|
||||
;
|
||||
(define
|
||||
(fact (lambda (n)
|
||||
(cond ((eq n 0) , 1)
|
||||
|
@ -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)
|
||||
|
@ -1,3 +1,6 @@
|
||||
;
|
||||
; Example from LISP 1.5 manual
|
||||
;
|
||||
(define
|
||||
(equal (lambda (x y)
|
||||
(cond ((and (atom x) (atom y)) (eq x y))
|
||||
|
@ -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))
|
||||
))
|
||||
|
@ -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)
|
||||
|
@ -1,3 +1,6 @@
|
||||
;
|
||||
; Sample from LISP 1.5 Manual
|
||||
;
|
||||
(define
|
||||
(ydot
|
||||
(lambda (x y)
|
||||
|
@ -1,3 +1,6 @@
|
||||
;
|
||||
; ALTERNATIVE MIN/MAX USING LIST ARGUMENT
|
||||
;
|
||||
(DEFINE
|
||||
(MINL (LAMBDA (M L)
|
||||
(COND ((NULL L), M)
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -1,3 +1,6 @@
|
||||
;
|
||||
; Example from LISP 1.5 manual
|
||||
;
|
||||
(define
|
||||
(member (lambda (a x)
|
||||
(cond ((null x) , f)
|
||||
|
Loading…
Reference in New Issue
Block a user