Changeset 2434 for lang/c/misc/mlisp/lib.l
- Timestamp:
- 12/04/07 22:42:46 (5 years ago)
- Files:
-
- 1 modified
-
lang/c/misc/mlisp/lib.l (modified) (4 diffs)
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
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)