(%compile-defvar ',name))
(setq ,name ,value)))
+(defvar nil 'nil)
+(defvar t 't)
+
(defmacro defun (name args &rest body)
`(progn
(eval-when-compile
(defun / (x y) (/ x y))
(defun 1+ (x) (+ x 1))
(defun 1- (x) (- x 1))
+(defun zerop (x) (= x 0))
+(defun not (x) (if x nil t))
+
+(defun truncate (x y) (floor (/ x y)))
+
(defun cons (x y ) (cons x y))
(defun car (x) (car x))
+(defun caar (x) (car (car x)))
+(defun cadr (x) (car (cdr x)))
(defun cdr (x) (cdr x))
+(defun cdar (x) (cdr (car x)))
+(defun cddr (x) (cdr (cdr x)))
(defun append (list1 list2)
(if (null list1)
(defun find-symbol (name)
(get *package* name))
+
+
+(defmacro cond (&rest clausules)
+ (if (null clausules)
+ nil
+ (if (eq (caar clausules) t)
+ `(progn ,@(cdar clausules))
+ `(if ,(caar clausules)
+ (progn ,@(cdar clausules))
+ (cond ,@(cdr clausules))))))
+
+(defun !reduce (func list initial)
+ (if (null list)
+ initial
+ (!reduce func
+ (cdr list)
+ (funcall func initial (car list)))))
+
+
+(defun code-char (x) x)
+(defun char-code (x) x)
+(defvar *newline* (string (code-char 10)))
+
+(defun concat (&rest strs)
+ (!reduce (lambda (s1 s2) (concat-two s1 s2))
+ strs
+ ""))
+
+;;; Concatenate a list of strings, with a separator
+(defun join (list separator)
+ (cond
+ ((null list)
+ "")
+ ((null (cdr list))
+ (car list))
+ (t
+ (concat (car list)
+ separator
+ (join (cdr list) separator)))))
+
+(defun join-trailing (list separator)
+ (if (null list)
+ ""
+ (concat (car list) separator (join-trailing (cdr list) separator))))
+
+(defun integer-to-string (x)
+ (if (zerop x)
+ "0"
+ (let ((digits nil))
+ (while (not (= x 0))
+ (push (mod x 10) digits)
+ (setq x (truncate x 10)))
+ (join (mapcar (lambda (d) (string (char "0123456789" d)))
+ digits)
+ ""))))
+
+(debug (integer-to-string 323))