使用インタープリタ:jpnslisp日本語Lisp for Linux2.19 または、
jpnslisp日本語Lisp3.19 以降
(defmacro push (x y)
`(setq ,y (cons ,x ,y)) )
(defmacro pop (y)
`(cond
((null ,y) nil)
(t
(prog1
(car ,y)
(setq ,y (cdr ,y)) ) ) ) )
(defmacro conc1f (x y)
`(if (null ,x) (setq ,x (list ,y))
(progn
(rplacd (last ,x) (list ,y))
,x ) ) )
(defun var? (x)
(and (symbolp x) (eql (aref (symbol-name x) 0) #\?)))
(defun varsym? (x)
(and (symbolp x) (eql (aref (symbol-name x) 0) #\?)))
(defun union (lst1 lst2)
(cond
((null lst1) lst2)
((member (car lst1) lst2)
(union (cdr lst1) lst2) )
(t (cons (car lst1) (union (cdr lst1) lst2))) ) )
(defun concatenate (type &rest b)
(let ()
(cond
((eql type 'string)
(cond
((not (is-all-string b)) (print '(some element is not a string)) nil)
(t (set-array (cons 1 (cons 'character (apply #'append (mapcar
(lambda (x)
(copy (cdr (array-cdr x))) ) b ) ) ) ) ) ) ) )
((eql type 'list)
(apply #'append (mapcar
(lambda (x)
(cond
((stringp x) (copy (cdr (array-cdr x))))
(t x) ) ) b ) ) )
(t (print '(bad usage for concatenate)) nil) ) ) )
(defun is-all-string (lst)
(cond
((atom lst) t)
((stringp (car lst)) (is-all-string (cdr lst)))
(t nil) ) )
(defmacro =defun (name parms &body body)
(let ((f (intern (concatenate 'string "=" (symbol-name name)))))
`(progn
(defmacro ,name ,parms
(list ',f '*cont* ,@parms))
(defun ,f (*cont* ,@parms) ,@body))))
defconstantはdefparameterで代用すること。
case文の条件tはotherwiseに変更すること。
&optionalは&restを使って記述し直すこと。
bindingの中のローカル関数recbindはグローバル関数にすること。
文字の比較にはeqではなくeqlを使うこと。
全ての(gensym)は(gensym "?")と書き直すこと。
以上で動く。