From: Ȳȣ��
Subject: How can I cast a string into integer ?
Date: 
Message-ID: <9ns9t5$eqq$1@hiline.shinbiro.com>
I'm novice in LISP.
I want a function which transform a string into number (Yea same as atoi()
in C)
is there any standard library function which is identical to C atoi() ?
Anyone please help me..

From: Frank A. Adrian
Subject: Re: How can I cast a string into integer ?
Date: 
Message-ID: <X9io7.996$x62.582245@news.uswest.net>
Ȳȣ�� wrote:

> I'm novice in LISP.
> I want a function which transform a string into number (Yea same as atoi()
> in C)
> is there any standard library function which is identical to C atoi() ?

Well, as the C library function atoi() works on C strings and produces a C 
integer, probably there's probably not one that's "identical".  You 
probably won't get overflow errors, either (i.e., you can parse the string 
"876439826926923469238696" into an integer and have it work!).

However, if you're looking for a Lisp function that converts a Lisp string 
to a Lisp integer, you might want to have a look at the function 
parse-integer.  It's much more versatile than the C function, allowing a 
radix to be specified, skipping whitespace before and after the string, 
allowing better error checking - all-in-all a quite nice function.

faa
From: Frederic Bastenaire
Subject: Re: How can I cast a string into integer ?
Date: 
Message-ID: <d977c973.0109140038.6169e856@posting.google.com>
> I want a function which transform a string into number (Yea same as atoi()
> in C)
There are many ways to do this, for example  :

(read-from-string "123") -> the number 123

Cheers,

FB
From: Espen Vestre
Subject: Re: How can I cast a string into integer ?
Date: 
Message-ID: <w6ofoe7xev.fsf@wallace.ws.nextra.no>
···@free.fr (Frederic Bastenaire) writes:

> There are many ways to do this, for example  :
> 
> (read-from-string "123") -> the number 123

it's better to use parse-integer if parsing an integer is what you
want to do. Some lisps, at least lispworks, will execute parse-integer
significantly faster than read-from-string.
-- 
  (espen)
From: Software Scavenger
Subject: Re: How can I cast a string into integer ?
Date: 
Message-ID: <a6789134.0109140215.7c6b57b6@posting.google.com>
"????" <·······@cs.hongik.ac.kr> wrote in message news:<············@hiline.shinbiro.com>...

> I want a function which transform a string into number (Yea same as atoi()

(parse-integer "123")
From: Eugene Zaikonnikov
Subject: Re: How can I cast a string into integer ?
Date: 
Message-ID: <680a835d.0109140444.61d0b190@posting.google.com>
"????" <·······@cs.hongik.ac.kr> wrote in message news:<············@hiline.shinbiro.com>...
> I'm novice in LISP.
> I want a function which transform a string into number (Yea same as atoi()
> in C)
> is there any standard library function which is identical to C atoi() ?
> Anyone please help me..

See your favorite reference for functions READ-FROM-STRING and PARSE-INTEGER.

--
  Eugene.
From: Nirved
Subject: Re: How can I cast a string into integer ?
Date: 
Message-ID: <15fb2d5b.0109140459.ea6327a@posting.google.com>
"????" <·······@cs.hongik.ac.kr> wrote in message news:<············@hiline.shinbiro.com>...
> I'm novice in LISP.
> I want a function which transform a string into number (Yea same as atoi()
> in C)
> is there any standard library function which is identical to C atoi() ?
> Anyone please help me..


http://www.xanalys.com/software_tools/reference/HyperSpec/Body/fun_parse-integer.html

:-)
From: Erik Winkels
Subject: Re: How can I cast a string into integer ?
Date: 
Message-ID: <87bskenszw.fsf@xs4all.nl>
Hi,

"Ȳȣ��" <·······@cs.hongik.ac.kr> writes:
> I want a function which transform a string into number (Yea same as
> atoi() in C)

"parse-integer" is what you are looking for.

    [1]> (1+ "666")
    *** - argument to 1+ should be a number: "666"
    1. Break [2]>
    [3]> (1+ (parse-integer "666"))
    667

See also:

    http://www.xanalys.com/software_tools/reference/HyperSpec/Body/fun_parse-integer.html#parse-integer

The HyperSpec can be downloaded from this page:

    http://www.xanalys.com/software_tools/reference/HyperSpec/
    (see the bottom of the page)


cheers,
Erik
From: Clive Tong
Subject: Re: How can I cast a string into integer ?
Date: 
Message-ID: <u3d5qywpo.fsf@scientia.com>
"Ȳȣ��" <·······@cs.hongik.ac.kr> writes:

> I'm novice in LISP.
> I want a function which transform a string into number (Yea same as atoi()
> in C)
> is there any standard library function which is identical to C atoi() ?
> Anyone please help me..

See parse-integer

  http://www.xanalys.com./software_tools/reference/HyperSpec/Body/fun_parse-integer.html
From: Kaz Kylheku
Subject: Re: How can I cast a string into integer ?
Date: 
Message-ID: <CSqo7.10285$jY.230059@news1.rdc1.bc.home.com>
In article <············@hiline.shinbiro.com>, ·······@cs.hongik.ac.kr wrote:

Note: please use only 7-bit characters in your message header
and body when posting to a Usenet discussion group (or at least
an English-language one).

>I'm novice in LISP.
>I want a function which transform a string into number (Yea same as atoi()
>in C)

You mean, you want a Lisp function that can reformat your hard drive or
make demons fly out of your nose if the number being converted cannot
be represented in the target type? :)

atoi is a dangerous function that should only be used when the
text of the number has been lexically verified to be convertible
without error, because the function has no means of reporting error,
and invokes undefined behavior if the integer is too large or too small.

Instead of atoi and atof, you should consider using the functions
strtol, strtoul and strtod.