Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I convert a string to integer in common lisp?

Tags:

How can I convert a string to integer in common lisp? For example, if I input a string "-64", I want to get an integer number -64. thx.

like image 984
snake Avatar asked Jun 12 '12 00:06

snake


People also ask

Can string be converted to integer in C#?

Call Convert methodsToInt32(String) method to convert an input string to an int. The example catches the two most common exceptions that can be thrown by this method, FormatException and OverflowException. If the resulting number can be incremented without exceeding Int32.

Can we use stoi in C?

What Is stoi() in C++? In C++, the stoi() function converts a string to an integer value. The function is shorthand for “string to integer,” and C++ programmers use it to parse integers out of strings. The stoi() function is relatively new, as it was only added to the language as of its latest revision (C++11) in 2011.

What is a string in Lisp?

A string in Emacs Lisp is an array that contains an ordered sequence of characters. Strings are used as names of symbols, buffers, and files; to send messages to users; to hold text being copied between buffers; and for many other purposes.


2 Answers

Fortunately, the standard provides a method: PARSE-INTEGER.

CL-USER> (parse-integer "-64") -64 3 
like image 92
Paul Nathan Avatar answered Sep 27 '22 20:09

Paul Nathan


This page may help:

http://hyperpolyglot.org/lisp

like image 32
MRAB Avatar answered Sep 27 '22 20:09

MRAB