From: Emre Sevinc
Subject: Making string comparison between a string and a symbol: Any easier way?
Date: 
Message-ID: <878y0eyav0.fsf@ileriseviye.org>
Assume I have my-string as:

"[PP [Spec Right]]"

And a list my-list as:

(PP (SPEC RIGHT))

Now, what do I do when I want to search, e.g. whether
the symbol RIGHT which is in *my-list* is also in
*my-string* in order to convert it to the right case 
(I mean from RIGHT to Right)?

Normally, search function complains when I try to
compare a symbol and a string:

CL-USER> (defvar *my-list* '(PP (SPEC RIGHT)))
*MY-LIST*
CL-USER> *my-list*
(PP (SPEC RIGHT))
CL-USER> (defvar *my-string* "[PP [Spec right]]")
*MY-STRING*
CL-USER> *my-string*
"[PP [Spec right]]"

CL-USER> (search (car *my-list*) *my-string*)
; Evaluation aborted

I have the following error:

The value PP is not of type SEQUENCE.
   [Condition of type TYPE-ERROR]

Is there a simple way to search (case-insensitively) 
for a symbol (by converting it to its string equivalent 
on-the-fly) in a string? (I had to use with-output-to-string
to solve my problem, but maybe there's a simpler way).


-- 
Emre Sevinc

eMBA Software Developer         Actively engaged in:
http:www.bilgi.edu.tr           http://ileriseviye.org
http://www.bilgi.edu.tr         http://fazlamesai.net
Cognitive Science Student       http://cazci.com
http://www.cogsci.boun.edu.tr

From: Eric Lavigne
Subject: Re: Making string comparison between a string and a symbol: Any easier way?
Date: 
Message-ID: <1121008246.891634.204120@o13g2000cwo.googlegroups.com>
>Is there a simple way to search (case-insensitively)
>for a symbol (by converting it to its string equivalent
>on-the-fly) in a string? (I had to use with-output-to-string
>to solve my problem, but maybe there's a simpler way).

(string-downcase 'PP) --> "pp"
(string-downcase "[PP [Spec right]]") --> "[pp [spec right]]"

Search for (string-downcase (car *my-list*))
in (string-downcase *my-string*)
From: Pascal Costanza
Subject: Re: Making string comparison between a string and a symbol: Any easier   way?
Date: 
Message-ID: <3jcrjiFoqbliU1@individual.net>
Emre Sevinc wrote:

> Is there a simple way to search (case-insensitively) 
> for a symbol (by converting it to its string equivalent 
> on-the-fly) in a string? (I had to use with-output-to-string
> to solve my problem, but maybe there's a simpler way).

Use SYMBOL-NAME.


Pascal

-- 
2nd European Lisp and Scheme Workshop
July 26 - Glasgow, Scotland - co-located with ECOOP 2005
http://lisp-ecoop05.bknr.net/
From: Emre Sevinc
Subject: Re: Making string comparison between a string and a symbol: Any easier way?
Date: 
Message-ID: <874qb2y8as.fsf@ileriseviye.org>
Pascal Costanza <··@p-cos.net> writes:

> Emre Sevinc wrote:
>
>> Is there a simple way to search (case-insensitively) for a symbol
>> (by converting it to its string equivalent on-the-fly) in a string?
>> (I had to use with-output-to-string
>> to solve my problem, but maybe there's a simpler way).
>
> Use SYMBOL-NAME.

Thank you; your suggestion helped me to get rid of with-output-to-string
and my code became 5 lines shorter (and easier to understand).


Happy hacking,

-- 
Emre Sevinc

eMBA Software Developer         Actively engaged in:
http:www.bilgi.edu.tr           http://ileriseviye.org
http://www.bilgi.edu.tr         http://fazlamesai.net
Cognitive Science Student       http://cazci.com
http://www.cogsci.boun.edu.tr
From: Pascal Bourguignon
Subject: Re: Making string comparison between a string and a symbol: Any easier way?
Date: 
Message-ID: <87zmsuk2ob.fsf@thalassa.informatimago.com>
Emre Sevinc <·····@bilgi.edu.tr> writes:

> Assume I have my-string as:
>
> "[PP [Spec Right]]"
>
> And a list my-list as:
>
> (PP (SPEC RIGHT))
>
> Now, what do I do when I want to search, e.g. whether
> the symbol RIGHT which is in *my-list* is also in
> *my-string* in order to convert it to the right case 
> (I mean from RIGHT to Right)?

If that matters, why didn't you preserve the case when reading the string?

[52]> (let ((*readtable* (copy-readtable)))
        (setf (readtable-case *readtable*) :preserve)
         (print (read-from-string "(PP  (Spec  Right))"))
         (values))

(PP (Spec Right)) 


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

Nobody can fix the economy.  Nobody can be trusted with their finger
on the button.  Nobody's perfect.  VOTE FOR NOBODY.
From: Emre Sevinc
Subject: Re: Making string comparison between a string and a symbol: Any easier way?
Date: 
Message-ID: <87wtnywo86.fsf@ileriseviye.org>
Pascal Bourguignon <···@informatimago.com> writes:

> Emre Sevinc <·····@bilgi.edu.tr> writes:
>
>> Assume I have my-string as:
>>
>> "[PP [Spec Right]]"
>>
>> And a list my-list as:
>>
>> (PP (SPEC RIGHT))
>>
>> Now, what do I do when I want to search, e.g. whether
>> the symbol RIGHT which is in *my-list* is also in
>> *my-string* in order to convert it to the right case 
>> (I mean from RIGHT to Right)?
>
> If that matters, why didn't you preserve the case when reading the string?
>
> [52]> (let ((*readtable* (copy-readtable)))
>         (setf (readtable-case *readtable*) :preserve)
>          (print (read-from-string "(PP  (Spec  Right))"))
>          (values))
>
> (PP (Spec Right)) 

Thank you very much for the suggestion, my code is getting shorter
and shorter :)



-- 
Emre Sevinc

eMBA Software Developer         Actively engaged in:
http:www.bilgi.edu.tr           http://ileriseviye.org
http://www.bilgi.edu.tr         http://fazlamesai.net
Cognitive Science Student       http://cazci.com
http://www.cogsci.boun.edu.tr