Show
Ignore:
Timestamp:
12/04/07 22:42:46 (5 years ago)
Author:
mokehehe
Message:
 
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/c/misc/mlisp/lib.l

    r2380 r2434  
    11 
    22(setq list 
    3           (lambda (nil . rest) 
    4                 rest)) 
     3      (lambda (nil . rest) 
     4        rest)) 
    55 
    66(defmacro defun (fname arg body) 
    77  (list 'setq fname 
    8                 (list 'lambda arg body))) 
     8        (list 'lambda arg body))) 
    99 
    1010(defun funcall (fn . x) 
     
    2929(defmacro all (x) 
    3030  (cond ((null x) t) 
    31                 ((car x) (list all (cdr x))) 
    32                 (t nil))) 
     31        ((car x) (list all (cdr x))) 
     32        (t nil))) 
    3333 
    3434; ���₵�� 
    3535(defmacro any (x) 
    3636  (cond ((null x) nil) 
    37                 ((car x) t) 
    38                 (t (list any (cdr x))))) 
     37        ((car x) t) 
     38        (t (list any (cdr x))))) 
    3939 
    4040(defun length (ls) 
    4141  (cond ((null ls) 0) 
    42                 (t (+ 1 (length (cdr ls)))))) 
     42        (t (+ 1 (length (cdr ls)))))) 
    4343 
    4444(defun mapcar (fn ls) 
    4545  (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)))))) 
    4848 
    4949 
     50(defun zerop (x) (eq x 0)) 
    5051(defun evenp (x) (eq (% x 2) 0)) 
    5152(defun oddp  (x) (eq (% x 2) 1)) 
     
    5758; �Q�‚̃��X�g�������(defun concat (x y) 
    5859  (cond ((null x) y) 
    59                 (t (cons (car x) 
    60                                 (concat (cdr x) y))))) 
     60        (t (cons (car x) 
     61                (concat (cdr x) y))))) 
    6162 
    6263; �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)))) 
    6767 
    6868 
     
    7777;(defmacro if (p tbody ebody) 
    7878;  (cond (p tbody) 
    79 ;               (t ebody))) 
     79;        (t ebody))) 
    8080 
    8181(defmacro if (test then else) 
    8282  (cons cond (cons (list test then) 
    83                                    (cond (else (list (list t else))))))) 
     83                   (cond (else (list (list t else))))))) 
    8484