help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to read an integer from the minibuffer


From: tomas
Subject: Re: How to read an integer from the minibuffer
Date: Sat, 13 Nov 2021 08:32:09 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Sat, Nov 13, 2021 at 09:46:10AM +0300, Jean Louis wrote:
> * Emanuel Berg via Users list for the GNU Emacs text editor 
> <help-gnu-emacs@gnu.org> [2021-11-13 00:21]:
> > tomas wrote:
> > 
> > > Why not simply numberp?
> > >
> > >   (and (numberp s) (string-to-number s))
> > 
> > King :)
> 
> (let ((s " 123"))
> (and (numberp s) (string-to-number s))) ⇒ nil

So leading spaces are to be ignored, OK. What about trailing
spaces? Exponential notation? Bases other than 10?

I think it's time you specify what a number is /for you/. Then
compare that with what a number is /for numberp/. Then rewrite
your program :)

> Example is here:
> 
> (let ((s " 123n"))
>   (string-to-number "123n")) ⇒ 123

Ah, but (numberp "123n") -> nil, so the and above would work.
Or, perhaps, "123n" should be a number? This is unclear from
what you say. At least to me.

Cheers
 - t

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]