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

.13

| 00:02 | .13 - わだばLisperになる を含むブックマーク はてなブックマーク - .13 - わだばLisperになる

日課練習、SRFI-1 lset系。

(defun lset-union (elt= &rest lists)
  (do ((l (reverse lists) (cdr l))
       (result '() (apply #'lset-adjoin elt= (car l) result)))
      ((null l) result)))

(defun lset-union (elt= &rest lists)
  (prog (result)
    L   (cond ((null lists) (return result)))
	(setq result (apply #'lset-adjoin elt= (pop lists) result))
	(go L)))

(defun lset-union (elt= &rest lists)
  (labels ((frob (elt= lists result)
	     (if (null lists)
		 result
		 (frob elt= 
		       (cdr lists)
		       (apply #'lset-adjoin elt= (car lists) result)))))
    (frob elt= (reverse lists) '() )))

;; ================================================================
(defun lset-adjoin (elt= list &rest elts)
  (if (functionp elt=)
      (reduce #'(lambda (retlst elt) (adjoin elt retlst :test elt=))
	      elts
	      :initial-value list)
      (error "bad type of argument for =")))

ゲスト



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