Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Fw: How to convert "((X))" to X

5 views
Skip to first unread message

Francesco Moi

unread,
Nov 30, 2001, 11:44:46 AM11/30/01
to
Hi all.

I'm NOT using Common Lisp, but a software wich must to be customized
by using a kind-of-Lisp: CoCreate SolidDesigner.

What I'm trying to do is comparing a String and a Symbol.

My String is: "John"
And my Symbol is: John

But always I test:
(string= Name1 Name2)... it's always NIL

And then my idea is removing quotes " " from Name1, or adding them to
Name2...

I do not know what to do...

>Francesco Moi wrote:
>
>>
>> The only thing I want is to REMOVE A CHAR FROM A STRING.
>
>Oh.
>
>> (remove #\5 "((5))")
>"(())"
>
>But i think that is not what you mean, since you are trying to add
stuff
>up. I think you want:
>
>(elt the-position-you-said-you had
>the-string-where-you-found-the-number)
>
>> (position #\5 "((5))")
>2
>
>(elt 2 "((5))")
>#\5
>
>but note that that is a character, not a number.
>
>read-from-string is what you want, and since your environment seems
not
>to offer that I wonder:
>
>What Lisp are you using?
>
>kenny
>clinisys

Kent M Pitman

unread,
Nov 30, 2001, 12:26:29 PM11/30/01
to
france...@europe.com (Francesco Moi) writes:

> I'm NOT using Common Lisp, but a software wich must to be customized
> by using a kind-of-Lisp: CoCreate SolidDesigner.
>
> What I'm trying to do is comparing a String and a Symbol.
>
> My String is: "John"
> And my Symbol is: John
>
> But always I test:
> (string= Name1 Name2)... it's always NIL

Symbols are upcased by default by the Lisp reader (its parser).
If you do:

(string= "John" 'John)

you are really executing

(STRING= "John" 'JOHN)

STRING= is a case-sensitive comparison. Use STRING-EQUAL or put
||'s around the symbol John to retain its case.

(string= "John" '|John|)


Erik Naggum

unread,
Nov 30, 2001, 1:48:58 PM11/30/01
to
* Francesco Moi

| I'm NOT using Common Lisp, but a software wich must to be customized
| by using a kind-of-Lisp: CoCreate SolidDesigner.

This information is crucial to get help. "Lisp" is not one language, but
the one people have a right to assume in the absence of antyhing else you
mean is Common Lisp. If you do know about the default, it is not an
error to overspecify.

| What I'm trying to do is comparing a String and a Symbol.

In Common Lisp, this works because a symbol is a string designator.
I.e., when you use a symbol in a string "context", what you get is really
(symbol-name symbol). This may not be true for other Lisp, so you may
have to make that function call explicitly.

| And then my idea is removing quotes " " from Name1, or adding them to
| Name2...

I hope you have made one of those changes at a time.

///
--
The past is not more important than the future, despite what your culture
has taught you. Your future observations, conclusions, and beliefs are
more important to you than those in your past ever will be. The world is
changing so fast the balance between the past and the future has shifted.

Marco Antoniotti

unread,
Nov 30, 2001, 2:22:14 PM11/30/01
to

france...@europe.com (Francesco Moi) writes:

> Hi all.
>
> I'm NOT using Common Lisp, but a software wich must to be customized
> by using a kind-of-Lisp: CoCreate SolidDesigner.

That explains a lot of the mis-communication. We are in presence of
an instance of Greenspun's Tenth Rule. :)

I do not think that many people on this group are familiar with the
"Lisp" implemented by the tool you are using. The answer that I gave
and saw were all relating to Common Lisp.

Cheers

--
Marco Antoniotti ========================================================
NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488
719 Broadway 12th Floor fax +1 - 212 - 995 4122
New York, NY 10003, USA http://bioinformatics.cat.nyu.edu
"Hello New York! We'll do what we can!"
Bill Murray in `Ghostbusters'.

Lieven Marchand

unread,
Nov 30, 2001, 11:51:12 AM11/30/01
to
france...@europe.com (Francesco Moi) writes:

> Hi all.
>
> I'm NOT using Common Lisp, but a software wich must to be customized
> by using a kind-of-Lisp: CoCreate SolidDesigner.
>
> What I'm trying to do is comparing a String and a Symbol.
>
> My String is: "John"
> And my Symbol is: John
>
> But always I test:
> (string= Name1 Name2)... it's always NIL
>
> And then my idea is removing quotes " " from Name1, or adding them to
> Name2...
>
> I do not know what to do...

You can try the two approaches:

(string= (symbol-name 'John) "JOHN")

or

(eql 'John (intern "JOHN"))

Note that I put the string in upper case. Common Lisp in default
reader mode will translate symbol names to upper. You might have to
experiment to see whether your Lisp implementation does the same.

--
Lieven Marchand <m...@wyrd.be>
She says, "Honey, you're a Bastard of great proportion."
He says, "Darling, I plead guilty to that sin."
Cowboy Junkies -- A few simple words

0 new messages