-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.ljsp
49 lines (41 loc) · 1.24 KB
/
test.ljsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
;;;; test.ljsp
;;; TODO: Test all the primitives exported from java
;; Do some bootstrapping to avoid depending in stuff.ljsp
;;; Bootstrapping BEGIN
(set (quote defun)
(macro (a)
(cons (quote set) (cons (cons (quote quote) (cons (car (cdr a)) nil)) (cons (cons (quote lambda) (cdr (cdr a))) nil)))))
;; IMPLEMENTED USING ONLY PRIMITIVES
(set (quote defmacro)
(macro (a)
(cons (quote set) (cons (cons (quote quote) (cons (car (cdr a)) nil)) (cons (cons (quote macro) (cdr (cdr a))) nil)))))
(defun end? (lst)
(if (atom? lst)
(if lst
(print (quote ERROL-not-list))
t)
nil))
(defun not (obj) (eq? obj nil))
(set (quote null?) not)
(defun cons? (obj) (not (atom? obj)))
(defun list? (lst)
(if (atom? lst)
(if lst nil t)
t))
(defun zero? (n) (= n 0))
(defun list (() . lst) lst)
(defun list* (arg . others)
(if (null? others)
arg
(if (null? (cdr others))
(cons arg (car others))
((lambda (roop)
(roop others)
(cons arg others))
(lambda (x)
(if (null? (cdr (cdr x)))
(rplacd x (car (cdr x)))
(roop (cdr x))))))))
;;; Bootstrapping END
(set 'tests nil)
(defmacro deftest (a))