-(eval-when-compile
- (%compile-defvar 'x))
-
-(setq x 10)
-(incf x)
-(debug x)
-
-;;; Conses
-(debug (cons 1 2))
-(debug (car (cons 1 2)))
-(debug (cdr (cons 1 2)))
-
-(setq x '(1 . 2))
-(debug x)
-(debug (eq x x))
-(debug (eq '(1 . 2) '(1 . 2)))
-
-;;; Symbols
-(debug (symbol-name 'foo))
-(debug (symbol-name 'foo-bar))
-
-(debug (progn 1 2 3 123))
-
-(debug (let ((x 99999))
- (incf x)))
-
-;;; &rest lambda-list
-
-(debug (lambda (&rest x) x))
-(debug (lambda (x y &rest z) z))
-(debug (lambda (x y &rest z) x))
-
-
-;; (eval-when-compile
-;; (%compile-defmacro 'defun
-;; (lambda (name args &rest body)
-;; (list 'eval-when-compile
-;; (list 'compile-defun)
-;; (list 'fsetq (list 'lambda args (list 'progn body)))))))
+(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 (zerop x 0))
+ (push (mod x 10) digits)
+ (setq x (truncate x 10)))
+ (join (mapcar (lambda (d) (string (char "0123456789" d)))
+ digits)
+ ""))))