Hatena::Groupcadr

わだばLisperになる このページをアンテナに追加 RSSフィード

2004 | 12 |
2005 | 01 | 02 | 07 | 10 | 11 |
2006 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2007 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2008 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2009 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2010 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
2011 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 11 |

2007-07-31

.17

| 21:22 | .17 - わだばLisperになる を含むブックマーク はてなブックマーク - .17 - わだばLisperになる

日課練習、SRFI-1 assoc系書き散らかし。

(defun alist-copy (alist)
  (mapcar (lambda (x) (cons (car x) (cdr x))) alist))

(defun alist-copy (alist)
  (prog (al result)
        (setq al alist)
    L	(cond ((endp al) (return (nreverse result))))
	(push (cons (caar al) (cdar al)) result)
	(pop al)
	(go L)))

(defun alist-copy (alist)
  (let (result)
    (dolist (l alist (nreverse result))
      (push (cons (car l) (cdr l)) result))))

(defun alist-copy (alist)
  (let (result)
    (mapc (lambda (item) 
	    (push (cons (car item) (cdr item)) result))
	  alist)
    (nreverse result)))

(defun alist-delete (key alist &optional (elt= #'equal))
  (let (result)
    (mapc (lambda (item) 
	    (and (funcall elt= key (car item))
		 (push item result)))
	    alist)
    result))

(defun alist-delete (key alist &optional (elt= #'equal))
  (do ((al alist (cdr al))
       (result))
      ((endp al) (nreverse result))
    (and (funcall elt= key (caar al)) (push (car al) result))))

(defun alist-delete (key alist &optional (elt= #'equal))
  (let (result)
    (dolist (al alist (nreverse result))
      (and (funcall elt= key (car al)) (push al result)))))

(defun alist-delete (key alist &optional (elt= #'equal))
  (reduce (lambda (r x) 
	    (if (funcall elt= key (car x))
		(cons x r)
		r))
	  alist
	  :initial-value '() ))

(defun alist-delete! (key alist &optional (elt= #'equal))
  (mapcan (lambda (item) (and (funcall elt= key (car item)) `(,item)))
	  alist))

ゲスト



トラックバック - http://cadr.g.hatena.ne.jp/g000001/20070731