X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fboot.lisp;h=ab043a92354e68672b81c443e7e66ace0f874d1c;hb=68cd2db6542fa3442d46b0331ecf8be8f86c09c2;hp=14d0ab90d5a97cc95186ecc16d97aad041131626;hpb=4410f136fe0502076d71b92a12774783ccdf6a4e;p=jscl.git diff --git a/src/boot.lisp b/src/boot.lisp index 14d0ab9..ab043a9 100644 --- a/src/boot.lisp +++ b/src/boot.lisp @@ -374,11 +374,6 @@ (defun atom (x) (not (consp x))) -(defun find (item list &key (key #'identity) (test #'eql)) - (dolist (x list) - (when (funcall test (funcall key x) item) - (return x)))) - (defun remove (x list) (cond ((null list) @@ -407,6 +402,10 @@ (t (remove-if-not func (cdr list))))) +(defun alpha-char-p (x) + (or (<= (char-code #\a) (char-code x) (char-code #\z)) + (<= (char-code #\Z) (char-code x) (char-code #\Z)))) + (defun digit-char-p (x) (if (and (<= (char-code #\0) (char-code x) (char-code #\9))) (- (char-code x) (char-code #\0)) @@ -440,6 +439,16 @@ (t (error "type-error!")))))) +(defun find (item sequence &key (key #'identity) (test #'eql)) + (do-sequence (x sequence) + (when (funcall test (funcall key x) item) + (return x)))) + +(defun find-if (predicate sequence &key (key #'identity)) + (do-sequence (x sequence) + (when (funcall predicate (funcall key x)) + (return x)))) + (defun some (function seq) (do-sequence (elt seq) (when (funcall function elt)