4 (%compile-defmacro 'defmacro
5 (lambda (name args &rest body)
7 (%compile-defmacro ',name (lambda ,args ,@body))))))
9 (defmacro defun (name args &rest body)
12 (%compile-defun ',name))
13 (fsetq ,name (lambda ,args ,@body))))
15 (defun + (x y) (+ x y))
16 (defun 1+ (x) (+ x 1))
17 (defun 1- (x) (- x 1))
19 (defun append (list1 list2)
23 (append (cdr list1) list2))))
25 (defun reverse-aux (list acc)
28 (reverse-aux (cdr list) (cons (car list) acc))))
31 (reverse-aux list '()))
33 (defun mapcar (func list)
36 (cons (funcall func (car list))
37 (mapcar func (cdr list)))))
39 (defun !reduce (func list initial)
44 (funcall func (car list) initial))))
52 (debug (if 2 (+ 2 1) 0))
53 (debug (= (+ 2 1) (- 4 1)))
56 (debug "---VARIABLES---")
58 (%compile-defvar 'name))
63 (debug "---FUNCTIONS---")
66 (fsetq f (lambda (x) (+ x 10)))
69 (debug ((lambda (x) x) 9999))
74 (debug "---MACROS---")
79 (list 'setq x (list '+ 1 x)))
90 (debug (car (cons 1 2)))
91 (debug (cdr (cons 1 2)))
96 (debug (eq '(1 . 2) '(1 . 2)))
99 (debug (symbol-name 'foo))
100 (debug (symbol-name 'foo-bar))
102 (debug (progn 1 2 3 123))
104 (debug (let ((x 99999))
107 ;;; &rest lambda-list
109 (debug (lambda (&rest x) x))
110 (debug (lambda (x y &rest z) z))
111 (debug (lambda (x y &rest z) x))
114 ;; (eval-when-compile
115 ;; (%compile-defmacro 'defun
116 ;; (lambda (name args &rest body)
117 ;; (list 'eval-when-compile
118 ;; (list 'compile-defun)
119 ;; (list 'fsetq (list 'lambda args (list 'progn body)))))))