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

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

`string-to-number' 0 (was: Re: count matches in string, not region?)


From: Emanuel Berg
Subject: `string-to-number' 0 (was: Re: count matches in string, not region?)
Date: Wed, 26 Feb 2020 06:04:08 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

>> This [last] I wrote a couple of nights ago,
>> it is part of my ISBN stuff [1] that will
>> soon be a MELPA package, God willing.
>> But more on that if and when it happens...
>
> Wait, that stuff is broke! OK, I'll fix it...
> But please respond to the original question
> anyway :)

Ah, its `thing-at-point', with Biblatex
entries, e.g.

;; @book{russian-arms-transfers-to-east,
;;   author     = {Alexander Sergounin},
;;   isbn       = {0-19-829576-6},
;;   publisher  = {Oxford},
;;   title      = {Russian Arms Transfers to East Asia in the 1990s},
;;   year       = 1999
;; }
;;
;; @book{baa-lo-4,
;;   author     = {Yukito Kishiro},
;;   isbn       = {978-1-61262-294-1},
;;   publisher  = {Kodansha},
;;   title      = {Battle Angel Alita: The Last Order 4},
;;   year       = {2014 (2011)}
;; }

it reads the curly brackets as well! OK,
question to, how do you drop everything from
a string that isn't an integer?

Maybe `cl-remove-if-not' but `string-to-number'
reports 0 both for string number 0 and strings
that are not numbers:

(string-to-number "a") ; 0
(string-to-number "0") ; 0
(string-to-number "1") ; 1

>From the docstring: "Return 0 if STRING cannot
be parsed as an integer or floating
point number."

Isn't that a bad idea? How do you know "a" from
the legit 0? Also, why return an integer to
signal DNC, when the purpose is to get
an integer?

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




reply via email to

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