unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: <tomas@tuxteam.de>
To: help-gnu-emacs@gnu.org
Subject: Re: compute ISBN-10, char-to-int?
Date: Thu, 5 Sep 2019 08:44:37 +0200	[thread overview]
Message-ID: <20190905064437.GA18252@tuxteam.de> (raw)
In-Reply-To: <868sr3le7s.fsf@zoho.eu>

[-- Attachment #1: Type: text/plain, Size: 890 bytes --]

On Thu, Sep 05, 2019 at 03:32:55AM +0200, Emanuel Berg via Users list for the GNU Emacs text editor wrote:
> Another quality release from
> uXu and THE SECRET EMPIRE [...]

> Anyway, questions:
> 
> that `char-to-int' looks a bit strange...

[...]

> (defun char-to-int (c)
>   (string-to-number (char-to-string c) ))

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
  - I don't know if that addresses your question

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 ;-)

Cheers
-- t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2019-09-05  6:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-05  1:32 compute ISBN-10, char-to-int? Emanuel Berg via Users list for the GNU Emacs text editor
2019-09-05  6:44 ` tomas [this message]
2019-09-05 17:28   ` Emanuel Berg via Users list for the GNU Emacs text editor
2019-09-05 18:08   ` Eli Zaretskii
2019-09-05 19:03     ` tomas
2019-09-05 19:16       ` Emanuel Berg via Users list for the GNU Emacs text editor
2019-09-06  6:58         ` Eli Zaretskii
2019-09-06  8:32           ` tomas
2019-09-06 15:07             ` Emanuel Berg via Users list for the GNU Emacs text editor
2019-09-06 18:02               ` Eli Zaretskii
2019-09-07 17:13       ` Stefan Monnier
2019-09-07 17:20         ` Eli Zaretskii
2019-09-07 17:45           ` Stefan Monnier
2019-09-07 18:30             ` Eli Zaretskii
2019-09-07 19:01               ` Stefan Monnier
2019-09-09 17:47         ` Emanuel Berg via Users list for the GNU Emacs text editor
2019-09-10  1:20           ` Perry Smith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190905064437.GA18252@tuxteam.de \
    --to=tomas@tuxteam.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).