diff options
Diffstat (limited to 'src/lisp/ao_lisp_const.lisp')
| -rw-r--r-- | src/lisp/ao_lisp_const.lisp | 35 | 
1 files changed, 33 insertions, 2 deletions
| diff --git a/src/lisp/ao_lisp_const.lisp b/src/lisp/ao_lisp_const.lisp index 621fefc4..08a511d9 100644 --- a/src/lisp/ao_lisp_const.lisp +++ b/src/lisp/ao_lisp_const.lisp @@ -14,9 +14,13 @@  (setq 1+ (lambda (x) (+ x 1)))  (setq 1- (lambda (x) (- x 1))) -					; define a variable without returning the value +					; +					; Define a variable without returning the value +					; Useful when defining functions to avoid +					; having lots of output generated +					; -(set 'def (macro (def-param) +(setq def (macro (def-param)  		 (list  		  'progn  		  (list @@ -127,3 +131,30 @@  		 )  		)       ) + +					; +					; A slightly more convenient form +					; for defining lambdas. +					; +					; (defun <name> (<params>) s-exprs) +					; + +(def defun (macro (defun-param) +		    (let ((name (car defun-param)) +			  (args (cadr defun-param)) +			  (exprs (cdr (cdr defun-param)))) +		      (list +		       def +		       name +		       (list +			'lambda +			args +			(cond ((cdr exprs) +			       (cons progn exprs)) +			      ((car exprs)) +			      ) +			) +		       ) +		      ) +		    ) +     ) | 
