From: Francesco Moi
Subject: How to convert "((X))" to X
Date: 
Message-ID: <5b829932.0111300146.d1343ae@posting.google.com>
Hi again

I'm trying to use a string as a numerical value. I mean, I've got a
list, I extracted a position from that list, I converted it to string
"((5))", and now I want to (setf Value (+ AnotherValue Value)).

But I get this error:
******************************
LISP error:
"((5))" is not a fixnum
******************************

Wich is the rightest way to carry it out? Thank you very much.

From: Marc Spitzer
Subject: Re: How to convert "((X))" to X
Date: 
Message-ID: <slrna0elun.2c6c.marc@oscar.eng.cv.net>
In article <···························@posting.google.com>, 
Francesco Moi wrote:
> Hi again
> 
> I'm trying to use a string as a numerical value. I mean, I've got a
> list, I extracted a position from that list, I converted it to string
> "((5))", and now I want to (setf Value (+ AnotherValue Value)).
> 
> But I get this error:
> ******************************
> LISP error:
> "((5))" is not a fixnum
> ******************************

(caar X)

marc

> 
> Wich is the rightest way to carry it out? Thank you very much.
From: Francesco Moi
Subject: Re: How to convert "((X))" to X
Date: 
Message-ID: <5b829932.0111300710.125be1f8@posting.google.com>
Hi all!.

Thank you very much for answer.

If I try:
> (CAAR (READ-FROM-STRING "((5))"))              
error: unbound function - READ-FROM-STRING       
> (caar "5")                                     
error: bad argument type - "5"                   
> (caar 5)                                       
error: bad argument type - 5                     
> (caar "5")                                     
error: bad argument type - "5"                   
> (caar "((5))")                                 
error: bad argument type - "((5))"               
> (caar "(5)")                                   
error: bad argument type - "(5)"  
> (caar '5)                  
error: bad argument type - 5 


The only thing I want is to REMOVE A CHAR FROM A STRING.
               

····@oscar.eng.cv.net (Marc Spitzer) wrote in message news:<····················@oscar.eng.cv.net>...
> In article <···························@posting.google.com>, 
> Francesco Moi wrote:
> > Hi again
> > 
> > I'm trying to use a string as a numerical value. I mean, I've got a
> > list, I extracted a position from that list, I converted it to string
> > "((5))", and now I want to (setf Value (+ AnotherValue Value)).
> > 
> > But I get this error:
> > ******************************
> > LISP error:
> > "((5))" is not a fixnum
> > ******************************
> 
> (caar X)
> 
> marc
> 
> > 
> > Wich is the rightest way to carry it out? Thank you very much.
From: Marco Antoniotti
Subject: Re: How to convert "((X))" to X
Date: 
Message-ID: <y6cadx4p8kn.fsf@octagon.mrl.nyu.edu>
············@europe.com (Francesco Moi) writes:

> Hi all!.
> 
> Thank you very much for answer.
> 
> If I try:
> > (CAAR (READ-FROM-STRING "((5))"))              
> error: unbound function - READ-FROM-STRING

Looks like you are not using Common Lisp.  What "Lisp" are you using?

> The only thing I want is to REMOVE A CHAR FROM A STRING.

Define "REMOVE".

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'.
From: Kenny Tilton
Subject: Re: How to convert "((X))" to X
Date: 
Message-ID: <3C07A5B5.B655A4FA@nyc.rr.com>
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
From: Kent M Pitman
Subject: Re: How to convert "((X))" to X
Date: 
Message-ID: <sfwvgfsdweg.fsf@shell01.TheWorld.com>
············@europe.com (Francesco Moi) writes:

> The only thing I want is to REMOVE A CHAR FROM A STRING.

(CHAR string n) gets you the Nth character (zero-indexed).
I suggest rather than removing the character from the string
(i.e., rather than making the string shorter) you just increment
the index and call CHAR again on the new index.
From: Frode Vatvedt Fjeld
Subject: Re: How to convert "((X))" to X
Date: 
Message-ID: <2h8zco19a1.fsf@dslab7.cs.uit.no>
············@europe.com (Francesco Moi) writes:

> The only thing I want is to REMOVE A CHAR FROM A STRING.

You need to understand the relationship between strings, characters
and integers, and the basics of lisp in general. If you know that you
have a string with a number starting at position 2, you can say

  (parse-integer "((5))" :start 2 :junk-allowed t)

-- 
Frode Vatvedt Fjeld
From: Frederic Brunel
Subject: Re: How to convert "((X))" to X
Date: 
Message-ID: <la3d2rnv5p.fsf@buzz.in-fusio.com>
> > The only thing I want is to REMOVE A CHAR FROM A STRING.
> 
> You need to understand the relationship between strings, characters
> and integers, and the basics of lisp in general. If you know that you
> have a string with a number starting at position 2, you can say
> 
>   (parse-integer "((5))" :start 2 :junk-allowed t)

In Lisp, you have access to the expression reader, why not simply use it?

  $ (read "((X))"))
  ((X))

You have turned your string in a Lisp object.

-- 
Frederic Brunel
Software Engineer
In-Fusio, The Mobile Fun Connection
From: Ole Rohne
Subject: Re: How to convert "((X))" to X
Date: 
Message-ID: <ebwadwzi1dy.fsf@lxplus027.cern.ch>
Frederic Brunel <··········@in-fusio.com> writes:

> In Lisp, you have access to the expression reader, why not simply
> use it?

There are reasons for not wanting to throw random unknown strings at
your lisp reader. #. is one of them.

>   $ (read "((X))"))
>   ((X))

You'd have to make that (read-from-string "((5))")

	Ole
From: Marco Antoniotti
Subject: Re: How to convert "((X))" to X
Date: 
Message-ID: <y6cpu60qov0.fsf@octagon.mrl.nyu.edu>
············@europe.com (Francesco Moi) writes:

> Hi again
> 
> I'm trying to use a string as a numerical value.

I see signs of acute Perlite here...

> I mean, I've got a
> list, I extracted a position from that list, I converted it to string
> "((5))", and now I want to (setf Value (+ AnotherValue Value)).
> 
> But I get this error:
> ******************************
> LISP error:
> "((5))" is not a fixnum
> ******************************
> 
> Wich is the rightest way to carry it out? Thank you very much.

What is your initial string?

The Right Way to to this is to use the functions READ, READ-LINE and
READ-FROM-STRING to parse your atring.  In the example above you do:

cl-prompt> (defvar *parsed-string* (read-from-string "((5))"))
*PARSED-STRING*

cl-prompt> *PARSED-STRING*
((5))

Note that the value of *PARSED-STRING* is now a list of a list which
contains a number.

cl-prompt> (defvar *the-number* (first (first *parsed-string*)))
*the-number*

cl-prompt> *the-number*
5

cl-prompt> (setf value (+ another-value *the-number*))
> ******************************
> LISP error:
> ANOTHER-VALUE is unbound.
> ******************************

Does this help?

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'.
From: Janis Dzerins
Subject: Re: How to convert "((X))" to X
Date: 
Message-ID: <9u7mai$tjs$1@milzis.latnet.lv>
············@europe.com (Francesco Moi) writes:

> I'm trying to use a string as a numerical value. 

String is a string, not a number, so you're doing something wrong.

But since you realize where the problem is you should fix that problem
(i.e. convert the string to a number). See function parse-integer.

> I mean, I've got a list, I extracted a position from that list, I
> converted it to string "((5))", and now I want to (setf Value (+
> AnotherValue Value)).

How do you "extract a position from a list", then convert it to string
and why? 

And I'm sure you dont want to (setf value ...) but change the value to
something else, setf being one way of doing it, but not the only one
and not the best one in this case.

> But I get this error:
> ******************************
> LISP error:
> "((5))" is not a fixnum
> ******************************

What Lisp do you use? Which one gives error messages formatted like
this? You don't provide enough details for us to even believe that
what you say you do is what you actually do.

> Wich is the rightest way to carry it out?

Please provide us with enough details if you want anybody to help
(because at least I don't believe you know what you are doing). And
please, don't post just the error message, but the transcript of all
your actions (assignments of initial values, "postion extraction",
convertions from lists to strings and the forms that trigger the
error) instead.

And, by the way, you don't need "the rightest" way (if there ever was
such a thing) but just a way, which might then be improved if
necessary.

-- 
Janis Dzerins

  Eat shit -- billions of flies can't be wrong.
From: Dr. Edmund Weitz
Subject: Re: How to convert "((X))" to X
Date: 
Message-ID: <m3elmgftza.fsf@bird.agharta.de>
············@europe.com (Francesco Moi) writes:

> Hi again
> 
> I'm trying to use a string as a numerical value. I mean, I've got a
> list, I extracted a position from that list, I converted it to string
> "((5))", and now I want to (setf Value (+ AnotherValue Value)).
> 
> But I get this error:
> ******************************
> LISP error:
> "((5))" is not a fixnum
> ******************************
> 
> Wich is the rightest way to carry it out? Thank you very much.

If you're really talking about a string:

  (CAAR (READ-FROM-STRING "((5))"))
  5

If your argument is already a list, CAAR will suffice.

However, after reading this and your previous postings, I'd suggest
that you try to learn at least some basics of Lisp before you carry on
with whatever you're doing. If this is homework, you should have some
reference material available, if not, you should get yourself a good
book or at least read the first chapters of some of the free tutorials
on the Web. See the bottom of
<http://groups.google.com/groups?selm=m3y9mzeh2u.fsf%40bird.agharta.de>
for some links.

Learning Lisp will also help you get rid of idioms like (SETF VALUE (+
ANOTHERVALUE VALUE)) which look suspiciously as if you're still
_thinking_ in BASIC (or Pascal, or C, or Java, or whatever procedural
language you've used before). If you try to write BASIC programs in
Lisp, Lisp will seem like a bad choice to you.

Cheers,
Edi.