[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to read an integer from the minibuffer
From: |
Jean Louis |
Subject: |
Re: How to read an integer from the minibuffer |
Date: |
Sat, 13 Nov 2021 09:36:39 +0300 |
User-agent: |
Mutt/2.0.7+183 (3d24855) (2021-05-28) |
* tomas@tuxteam.de <tomas@tuxteam.de> [2021-11-12 23:25]:
> On Fri, Nov 12, 2021 at 11:02:10PM +0300, Jean Louis wrote:
> > Improved check for number:
> >
> > (defun string-is-number-p (s)
> > "Return number only if string is actual number, otherwise NIL."
> > (let* ((s (string-trim s)))
> > (cond ((seq-empty-p s) nil)
> > ((string-match "[^0123456789\\.-]" s) nil)
> > ((string-match "-" s 1) nil)
> > ((numberp (string-to-number s)) (string-to-number s)))))
>
> Why not simply numberp?
>
> (and (numberp s) (string-to-number s))
(numberp "123") ⇒ nil
It checks if object is number. That is why it is not usable to check
if string is actual number.
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
- Re: How to read an integer from the minibuffer, (continued)
- Re: How to read an integer from the minibuffer, Emanuel Berg, 2021/11/16
- Re: How to read an integer from the minibuffer, Jean Louis, 2021/11/12
- Re: How to read an integer from the minibuffer, Jean Louis, 2021/11/12
- Re: How to read an integer from the minibuffer, tomas, 2021/11/12
- Re: How to read an integer from the minibuffer, Emanuel Berg, 2021/11/12
- Re: How to read an integer from the minibuffer, tomas, 2021/11/12
- Re: How to read an integer from the minibuffer, Emanuel Berg, 2021/11/12
- Re: How to read an integer from the minibuffer, Jean Louis, 2021/11/13
- Re: How to read an integer from the minibuffer, tomas, 2021/11/13
- Re: How to read an integer from the minibuffer, Emanuel Berg, 2021/11/16
- Re: How to read an integer from the minibuffer,
Jean Louis <=
- Re: How to read an integer from the minibuffer, tomas, 2021/11/13
- Re: How to read an integer from the minibuffer, Jean Louis, 2021/11/13
- Re: How to read an integer from the minibuffer, Emanuel Berg, 2021/11/16
- Re: How to read an integer from the minibuffer, Emanuel Berg, 2021/11/16
- Re: How to read an integer from the minibuffer, Emanuel Berg, 2021/11/11
- Re: How to read an integer from the minibuffer, Gregory Heytings, 2021/11/11
- Re: How to read an integer from the minibuffer, Emanuel Berg, 2021/11/11
Re: How to read an integer from the minibuffer, Marcin Borkowski, 2021/11/12