projects
/
jscl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
MOD, FLOOR
[jscl.git]
/
test.lisp
diff --git
a/test.lisp
b/test.lisp
index
4b6e015
..
0529823
100644
(file)
--- a/
test.lisp
+++ b/
test.lisp
@@
-1,65
+1,64
@@
-(lambda (x y)
- x)
+;;; Library
-(debug "hola")
-(debug '(1 2 3 4))
-(debug (if 2 (+ 2 1) 0))
-(debug (= (+ 2 1) (- 4 1)))
-
-;;; Variables
-(debug "---VARIABLES---")
(eval-when-compile
(eval-when-compile
- (%compile-defvar 'name))
-(setq name 10)
-(debug name)
+ (%compile-defmacro 'defmacro
+ (lambda (name args &rest body)
+ `(eval-when-compile
+ (%compile-defmacro ',name (lambda ,args ,@body))))))
-;;; Functions
-(debug "---FUNCTIONS---")
-(eval-when-compile
- (%compile-defun 'f))
-(fsetq f (lambda (x) (+ x 10)))
-(debug (f 20))
+(defmacro defvar (name value)
+ `(progn
+ (eval-when-compile
+ (%compile-defvar ',name))
+ (setq ,name ,value)))
-;;; Macros
-(debug "---MACROS---")
+(defmacro defun (name args &rest body)
+ `(progn
+ (eval-when-compile
+ (%compile-defun ',name))
+ (fsetq ,name (lambda ,args ,@body))))
-(eval-when-compile
- (%compile-defmacro 'defmacro
- (lambda (name args &rest body)
- (list 'eval-when-compile
- (list '%compile-defmacro (list 'quote name)
- (list* 'lambda args body))))))
-
-(defmacro incf (x)
- (list 'setq x (list '+ 1 x)))
+(defun = (x y) (= x y))
+(defun + (x y) (+ x y))
+(defun - (x y) (- x y))
+(defun * (x y) (* x y))
+(defun / (x y) (/ x y))
+(defun 1+ (x) (+ x 1))
+(defun 1- (x) (- x 1))
+(defun cons (x y ) (cons x y))
+(defun car (x) (car x))
+(defun cdr (x) (cdr x))
-(eval-when-compile
- (%compile-defvar 'x))
+(defun append (list1 list2)
+ (if (null list1)
+ list2
+ (cons (car list1)
+ (append (cdr list1) list2))))
-(setq x 10)
-(incf x)
-(debug x)
+(defun reverse-aux (list acc)
+ (if (null list)
+ acc
+ (reverse-aux (cdr list) (cons (car list) acc))))
-;;; Conses
-(debug (cons 1 2))
-(debug (car (cons 1 2)))
-(debug (cdr (cons 1 2)))
+(defun reverse (list)
+ (reverse-aux list '()))
-;;; Symbols
-(debug (symbol-name 'foo))
-(debug (symbol-name 'foo-bar))
+(defun mapcar (func list)
+ (if (null list)
+ '()
+ (cons (funcall func (car list))
+ (mapcar func (cdr list)))))
-;;; &rest lambda-list
+(defmacro push (x place)
+ `(setq ,place (cons ,x ,place)))
-(debug (lambda (&rest x) x))
-(debug (lambda (x y &rest z) z))
-(debug (lambda (x y &rest z) x))
+(defvar *package* (new))
-;; (debug (foo))
+(defun intern (name)
+ (let ((s (get *package* name)))
+ (if s
+ s
+ (set *package* name (make-symbol name)))))
-;; (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 find-symbol (name)
+ (get *package* name))