Skip to content

Commit

Permalink
Simplify `define-transitive-relation'.
Browse files Browse the repository at this point in the history
  • Loading branch information
davazp committed Feb 10, 2010
1 parent d688cf8 commit 50137bf
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions utils.lisp
Expand Up @@ -58,14 +58,11 @@


(defmacro define-transitive-relation (name (arg1 arg2) &body body)
(with-gensyms (argsvar i)
(with-gensyms (argsvar)
`(defun ,name (&rest ,argsvar)
(do ((,i ,argsvar (cdr ,i)))
((null (cdr ,i)) t)
(let ((,arg1 (first ,i))
(,arg2 (second ,i)))
(or (block nil ,@body)
(return nil)))))))
(loop for (,arg1 ,arg2) on ,argsvar
while ,arg2
always (block nil ,@body)))))

(defun strip-if (func seq &rest rest &key &allow-other-keys)
(subseq seq 0 (apply #'position-if func seq rest)))
Expand Down Expand Up @@ -98,4 +95,5 @@
do (error "Character ~w is not expected." ch)
do (write-char (read-char stream) out)))))


;;; utils.lisp ends here

0 comments on commit 50137bf

Please sign in to comment.