From: Christian Soltenborn
Subject: How to search for an atom in another atom
Date: 
Message-ID: <bv1hdj$mvati$1@ID-36219.news.uni-berlin.de>
Hi folks,

I just started to learn Lisp, and I have a small question: I have to 
write a function which checks if an atom is contained in another atom. 
For example:

 >(setf expr 'xyz)
XYZ
 > (checkp 'x expr)
T
 >(checkp 'a expr)
NIL

Unfortunately I have no clue how I can access the single "chars" of an 
atom. And it is kind of hard to find this information if you don't know 
for which function to search. Could somebody give me a hint?

Thanks in advance,
Christian

From: Paul Rubin
Subject: Re: How to search for an atom in another atom
Date: 
Message-ID: <7xfze3r62b.fsf@ruckus.brouhaha.com>
Christian Soltenborn <···················@webmail.de> writes:
> Unfortunately I have no clue how I can access the single "chars" of an
> atom. And it is kind of hard to find this information if you don't
> know for which function to search. Could somebody give me a hint?

You've been reading docs from the ancient days of Lisp.  It's not
normal to use symbols as strings any more.  Most Lisps have a string
datatype.  But if you really want to get out the name of a symbol,
use

   (symbol-name 'xyz)  =>  "xyz"
From: Rahul Jain
Subject: Re: How to search for an atom in another atom
Date: 
Message-ID: <87smi3r132.fsf@nyct.net>
Christian Soltenborn <···················@webmail.de> writes:

> I just started to learn Lisp, and I have a small question: I have to
> write a function which checks if an atom is contained in another
> atom.

An atom is to be treated atomically. Note that the term "atom" is an
anacrhonism. Structures are "atoms", as are arrays.

It seems that you're trying to see if some substring of a symbol name is
the name of another symbol. Why not use strings from the start if you're
doing a substring search? You can use the wonderful sequences library
that is provided by all Lisp implementations to do your searching. E.g.,
you might want to look at POSITION, FIND, and SUBSEQ.

-- 
Rahul Jain
·····@nyct.net
Professional Software Developer, Amateur Quantum Mechanicist
From: Wade Humeniuk
Subject: Re: How to search for an atom in another atom
Date: 
Message-ID: <DYXQb.14322$5D.7846@clgrps13>
Christian Soltenborn wrote:
> Hi folks,
> 
> I just started to learn Lisp, and I have a small question: I have to 
> write a function which checks if an atom is contained in another atom. 
> For example:
> 
>  >(setf expr 'xyz)
> XYZ
>  > (checkp 'x expr)
> T
>  >(checkp 'a expr)
> NIL
> 
> Unfortunately I have no clue how I can access the single "chars" of an 
> atom. And it is kind of hard to find this information if you don't know 
> for which function to search. Could somebody give me a hint?

CL-USER 3 > (find 'x (string 'xyz) :test 'string=)
#\X

CL-USER 4 > (find 'a (string 'xyz) :test 'string=)
NIL

CL-USER 5 >

Wade
From: Wade Humeniuk
Subject: Re: How to search for an atom in another atom
Date: 
Message-ID: <rP_Qb.14920$5D.12984@clgrps13>
Wade Humeniuk wrote:

> 
> CL-USER 3 > (find 'x (string 'xyz) :test 'string=)
> #\X
> 
> CL-USER 4 > (find 'a (string 'xyz) :test 'string=)
> NIL
> 
> CL-USER 5 >

If I have not totally screwed you up, the hint should be

CL-USER 4 > (search (string 'a) (string 'abc) :test 'string=)
0

CL-USER 5 > (search (string 'x) (string 'abc) :test 'string=)
NIL

CL-USER 6 >

Wade