From: DaveNlp
Subject: Does a function like strpbrk exist?
Date: 
Message-ID: <3J_7b.310887$lK4.9732484@twister1.libero.it>
(DEFUN strpbrk (charray chars)
    (LET* ((lens (LENGTH chars)))
        (DOTIMES (i lens)
            (IF (SEARCH (STRING (CHAR chars i)) charray)
                (RETURN T)))))

(IF (strpbrk "*string.." ".*")
    (print "Characters found.")
    (print "Characters not found."))

In C, the strpbrk function locates the first occurrence 
in the string pointed to by s1 of any character from the string pointed to by s2.
Is there another smaller function to do this in Lisp?

Thank You.
DaveNlp

From: Pascal Costanza
Subject: Re: Does a function like strpbrk exist?
Date: 
Message-ID: <bjpubm$sl2$1@f1node01.rhrz.uni-bonn.de>
DaveNlp wrote:
> (DEFUN strpbrk (charray chars)
>     (LET* ((lens (LENGTH chars)))
>         (DOTIMES (i lens)
>             (IF (SEARCH (STRING (CHAR chars i)) charray)
>                 (RETURN T)))))
> 
> (IF (strpbrk "*string.." ".*")
>     (print "Characters found.")
>     (print "Characters not found."))
> 
> In C, the strpbrk function locates the first occurrence 
> in the string pointed to by s1 of any character from the string pointed to by s2.
> Is there another smaller function to do this in Lisp?

Something like this should work:

(position-if (lambda (c) (find c ".*")) "*string..")


Pascal


-- 
Pascal Costanza               University of Bonn
···············@web.de        Institute of Computer Science III
http://www.pascalcostanza.de  R�merstr. 164, D-53117 Bonn (Germany)
From: Wolfhard Buß
Subject: Re: Does a function like strpbrk exist?
Date: 
Message-ID: <m3r82nmm1n.fsf@buss-14250.user.cis.dfn.de>
DaveNlp:
> (DEFUN strpbrk (charray chars)
>     (LET* ((lens (LENGTH chars)))
>         (DOTIMES (i lens)
>             (IF (SEARCH (STRING (CHAR chars i)) charray)
>                 (RETURN T)))))
> (IF (strpbrk "*string.." ".*")
>
>     (print "Characters found.")
>     (print "Characters not found."))
> In C, the strpbrk function locates the first occurrence in the
> string pointed to by s1 of any character from the string pointed to
> by s2.
>
> Is there another smaller function to do this in Lisp?

Pascal Costanza:
> Something like this should work:
> 
> (position-if (lambda (c) (find c ".*")) "*string..")


Note quite. DaveNlp is looking for a subsequence. 


-- 
"Hurry if you still want to see something. Everything is vanishing."
                                       --  Paul C�zanne (1839-1906)
From: Jock Cooper
Subject: Re: Does a function like strpbrk exist?
Date: 
Message-ID: <m3isnznu4t.fsf@jcooper02.sagepub.com>
·····@gmx.net (Wolfhard Bu�) writes:

> DaveNlp:
> > (DEFUN strpbrk (charray chars)
> >     (LET* ((lens (LENGTH chars)))
> >         (DOTIMES (i lens)
> >             (IF (SEARCH (STRING (CHAR chars i)) charray)
> >                 (RETURN T)))))
> > (IF (strpbrk "*string.." ".*")
> >
> >     (print "Characters found.")
> >     (print "Characters not found."))
> > In C, the strpbrk function locates the first occurrence in the
> > string pointed to by s1 of any character from the string pointed to
> > by s2.
> >
> > Is there another smaller function to do this in Lisp?
> 
> Pascal Costanza:
> > Something like this should work:
> > 
> > (position-if (lambda (c) (find c ".*")) "*string..")
> 
> 
> Note quite. DaveNlp is looking for a subsequence. 
> 

so just a little wrapper code gives:

(defun strpbrk (s1 s2)
  (let ((pos (position-if (lambda (c) (find c s2)) s1)))
    (if pos (subseq s1 pos))))
From: DaveNlp
Subject: Re: Does a function like strpbrk exist?
Date: 
Message-ID: <6p38b.311852$lK4.9755151@twister1.libero.it>
"Jock Cooper" <·····@mail.com> writes:
> > 
> > Note quite. DaveNlp is looking for a subsequence. 
> > 
> 
> so just a little wrapper code gives:
> 
> (defun strpbrk (s1 s2)
>   (let ((pos (position-if (lambda (c) (find c s2)) s1)))
>     (if pos (subseq s1 pos))))

Your solution is perfect!, 
even if it was not closely necessary. :)

Thanks you very much.
Greetings.
Dave