Changeset 2434
- Timestamp:
- 12/04/07 22:42:46 (5 years ago)
- Location:
- lang/c/misc/mlisp
- Files:
-
- 4 modified
-
lib.l (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
-
src/mlisp.h (modified) (1 diff)
-
test.l (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/c/misc/mlisp/lib.l
r2380 r2434 1 1 2 2 (setq list 3 (lambda (nil . rest)4 rest))3 (lambda (nil . rest) 4 rest)) 5 5 6 6 (defmacro defun (fname arg body) 7 7 (list 'setq fname 8 (list 'lambda arg body)))8 (list 'lambda arg body))) 9 9 10 10 (defun funcall (fn . x) … … 29 29 (defmacro all (x) 30 30 (cond ((null x) t) 31 ((car x) (list all (cdr x)))32 (t nil)))31 ((car x) (list all (cdr x))) 32 (t nil))) 33 33 34 34 ; ���₵�� 35 35 (defmacro any (x) 36 36 (cond ((null x) nil) 37 ((car x) t)38 (t (list any (cdr x)))))37 ((car x) t) 38 (t (list any (cdr x))))) 39 39 40 40 (defun length (ls) 41 41 (cond ((null ls) 0) 42 (t (+ 1 (length (cdr ls))))))42 (t (+ 1 (length (cdr ls)))))) 43 43 44 44 (defun mapcar (fn ls) 45 45 (cond ((eq ls nil) nil) 46 (t (cons (fn (car ls))47 (mapcar fn (cdr ls))))))46 (t (cons (fn (car ls)) 47 (mapcar fn (cdr ls)))))) 48 48 49 49 50 (defun zerop (x) (eq x 0)) 50 51 (defun evenp (x) (eq (% x 2) 0)) 51 52 (defun oddp (x) (eq (% x 2) 1)) … … 57 58 ; �Q�̃��X�g�������(defun concat (x y) 58 59 (cond ((null x) y) 59 (t (cons (car x)60 (concat (cdr x) y)))))60 (t (cons (car x) 61 (concat (cdr x) y))))) 61 62 62 63 ; �C�ӌ̃��X�g�������(defun append (nil . x) 63 (cond ((cdr x) 64 (concat (car x) 65 (apply append (cdr x)))) 66 (t (car x)))) 64 (cond ((cdr x) (concat (car x) 65 (apply append (cdr x)))) 66 (t (car x)))) 67 67 68 68 … … 77 77 ;(defmacro if (p tbody ebody) 78 78 ; (cond (p tbody) 79 ; (t ebody)))79 ; (t ebody))) 80 80 81 81 (defmacro if (test then else) 82 82 (cons cond (cons (list test then) 83 (cond (else (list (list t else)))))))83 (cond (else (list (list t else))))))) 84 84 -
lang/c/misc/mlisp/readme.txt
r2387 r2434 44 44 - �_�C�i�~�b�N�X�R�[�v 45 45 - �K�x�R���Ȃ� 46 - �C���^�v���^ 46 47 47 48 -
lang/c/misc/mlisp/src/mlisp.h
r2378 r2434 84 84 85 85 /// macros 86 #define SEXP_IS_INT(a) (((a) & 1) == 1)86 #define SEXP_IS_INT(a) (((a) & 1) != 0) 87 87 #define SEXP_TYPE(a) ((a) & ~VAL_MASK) 88 88 #define SEXP_CONSP(a) (SEXP_TYPE(a) == tCell) -
lang/c/misc/mlisp/test.l
r2380 r2434 2 2 (defun concat (x y) 3 3 (cond ((null x) y) 4 (t (cons (car x)5 (concat (cdr x) y)))))4 (t (cons (car x) 5 (concat (cdr x) y))))) 6 6 7 7 (defun append (nil . x) 8 8 (cond ((cdr x) 9 (concat (car x)10 (apply append (cdr x))))11 (t (car x))))9 (concat (car x) 10 (apply append (cdr x)))) 11 (t (car x)))) 12 12 13 13
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)