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-28

.15

| 18:45 | .15 - わだばLisperになる を含むブックマーク はてなブックマーク - .15 - わだばLisperになる

日課練習、SRFI-1 find、find-tail 簡単なものを作る

のが好きだー。

(defun srfi-find (pred clist)
  (find-if pred clist))

(defun srfi-find (pred clist)
  (do ((l clist (cdr l)))
      ((null l) nil)
    (and (funcall pred (car l))
	 (return (car l)))))

(defun srfi-find (pred clist)
  (prog nil
    L   (cond ((null clist) (return nil)))
	(and (funcall pred (car clist)) (return (car clist)))
	(pop clist)
	(go L)))

(defun srfi-find (pred clist)
  (dolist (l clist nil)
    (and (funcall pred l) (return l))))

(defun srfi-find (pred clist)
  (prog nil
    (mapc (lambda (x) (and (funcall pred x) (return x))) 
	  clist)))

(defun srfi-find (pred clist)
  (block nil
    (mapc (lambda (x) 
	    (and (funcall pred x) (return x))) 
	  clist)))

;; ================================================================
(defun find-tail (pred clist)
  (prog nil
    L   (cond ((null clist) (return nil)))
	(and (funcall pred (car clist)) (return clist))
	(pop clist)
	(go L)))

(defun find-tail (pred clist)
  (prog nil
        (mapl #'(lambda (x)
		  (and (funcall pred (car x)) (return x)))
	      clist)))

(defun find-tail (pred clist)
  (block nil
    (mapl #'(lambda (x) 
	      (and (funcall pred (car x)) (return x)))
	  clist)))

(defun find-tail (pred clist)
  (do ((l clist (cdr l)))
      ((null l) nil)
    (and (funcall pred (car l)) (return l))))

(defun find-tail (pred clist)
  (loop for l on clist 
        do (when (funcall pred (car l)) (return l))))

ゲスト



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