[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: compute ISBN-10, char-to-int?
From: |
Emanuel Berg |
Subject: |
Re: compute ISBN-10, char-to-int? |
Date: |
Thu, 05 Sep 2019 19:28:44 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) |
tomas wrote:
> It looks a bit roundabout, sure. But how
> would you do it without making any
> assumptions about the underlying encoding?
>
> If you have no scruples, and since chars in
> Emacs Lisp are simply integers, and since
> encoding is almost-UTF-8 which is basically
> ASCII, you could do
>
> (defun char-to-int (c)
> (- c ?0))
>
> but...
>
> - it's ugly
Why, I think it's great! New version:
<https://dataswamp.org/~incal/emacs-init/isbn-new.el>
> - I don't know if that addresses your
> question
Me neither... wait, what was my
question exactly?
Yeah, why isn't there a "char-to-int" in
vanilla Emacs already? Should be a pretty
standard thing, right?
> It would be faster, yes. But that will start
> to count once we have ISBN-4294967296 or
> something. By then, you'll have a faster
> computer, too ;-)
... I'm not following? :)
That isn't a valid ISBN-10, the checksum
(check digit) is 3:
(mod (- 11 (mod (+ (* 4 10)
(* 2 9)
(* 9 8)
(* 4 7)
(* 9 6)
(* 6 5)
(* 7 4)
(* 2 3)
(* 9 2))
11)) 11) ; 3
(checksum-isbn-10 "4294967296") ; 3
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
- compute ISBN-10, char-to-int?, Emanuel Berg, 2019/09/04
- Re: compute ISBN-10, char-to-int?, tomas, 2019/09/05
- Re: compute ISBN-10, char-to-int?,
Emanuel Berg <=
- Re: compute ISBN-10, char-to-int?, Eli Zaretskii, 2019/09/05
- Re: compute ISBN-10, char-to-int?, tomas, 2019/09/05
- Re: compute ISBN-10, char-to-int?, Emanuel Berg, 2019/09/05
- Re: compute ISBN-10, char-to-int?, Eli Zaretskii, 2019/09/06
- Re: compute ISBN-10, char-to-int?, tomas, 2019/09/06
- Re: compute ISBN-10, char-to-int?, Emanuel Berg, 2019/09/06
- Re: compute ISBN-10, char-to-int?, Eli Zaretskii, 2019/09/06
- Re: compute ISBN-10, char-to-int?, Stefan Monnier, 2019/09/07
- Re: compute ISBN-10, char-to-int?, Eli Zaretskii, 2019/09/07
- Re: compute ISBN-10, char-to-int?, Stefan Monnier, 2019/09/07